Kotlin 外卖 APP

首页布局代码

代码

class HomeFragment : Fragment(){lateinit var homeRvAdapter: HomeAdapterlateinit var rvHome :RecyclerViewoverride fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {val view = View.inflate(activity as Context?, R.layout.fragment_home, null)rvHome = view.find<RecyclerView>(R.id.rv_home) //从上到 // 下的列表视图rvHome.layoutManager = LinearLayoutManager(activity)homeRvAdapter = HomeAdapter(activity)rvHome.adapter = homeRvAdapterdistance = 170.dp2px()return view}fun Int.dp2px() :Int{return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,toFloat(),resources.displayMetrics).toInt()}override fun onActivityCreated(savedInstanceState: Bundle?) {super.onActivityCreated(savedInstanceState)initData()}val datas : ArrayList<String> = ArrayList()var sum : Int = 0var distance : Int = 0var alpha = 55private fun initData() {datas.clear()for (i in 0 until 20){datas.add("我是商家:"+i)}homeRvAdapter.setData(datas)//有数据可以滚动才可以监听滚动时间rvHome.setOnScrollListener(object : RecyclerView.OnScrollListener(){override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {}override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {super.onScrolled(recyclerView, dx, dy)sum += dyif (sum > distance){alpha = 255}else{alpha = (sum / distance)alpha += 55}ll_title_container.setBackgroundColor(Color.argb(alpha,0x31,0x90,0xe8))}})}
}

布局

<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"><android.support.v7.widget.RecyclerViewandroid:layout_width="match_parent"android:layout_height="match_parent"android:id="@+id/rv_home"></android.support.v7.widget.RecyclerView><LinearLayoutandroid:id="@+id/ll_title_container"android:layout_width="match_parent"android:layout_height="wrap_content"android:background="#553190E8"android:orientation="horizontal"android:layout_alignParentTop="true"android:layout_alignParentLeft="true"android:layout_alignParentStart="true"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="50dp"android:id="@+id/ll_title_search"android:orientation="horizontal"android:layout_marginTop="30dp"><LinearLayoutandroid:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="2"android:orientation="horizontal"><TextViewandroid:id="@+id/home_tv_address"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center_vertical"android:layout_marginLeft="5dip"android:layout_weight="1"android:singleLine="true"android:text="昌平区北七家宏福创业园修正大厦"android:textColor="#FFF"/><ImageViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center_vertical"android:layout_marginRight="5dip"android:src="@drawable/home_address_drop_dowm"/></LinearLayout><LinearLayoutandroid:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="3"android:layout_marginBottom="12dp"android:layout_marginRight="10dp"android:layout_marginTop="12dp"android:background="@drawable/home_search_text_background"><LinearLayoutandroid:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="1"android:layout_marginRight="10dip"android:layout_gravity="center_vertical"android:orientation="horizontal"><ImageViewandroid:layout_width="15sp"android:layout_height="15sp"android:layout_gravity="center_vertical"android:layout_marginLeft="4dp"android:src="@drawable/home_search"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center_vertical"android:text="输入商家、商品名称"android:textColor="#FFF"android:textSize="12sp"/></LinearLayout></LinearLayout></LinearLayout></LinearLayout>
</RelativeLayout>

行布局

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto"android:orientation="horizontal"android:background="#fff"><FrameLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"><com.makeramen.roundedimageview.RoundedImageViewapp:riv_oval="true"android:layout_width="90dp"android:layout_height="90dp"android:layout_margin="8dp"android:src="@drawable/item_kfc"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:id="@+id/seller_logo"android:layout_margin="8dp"android:layout_gravity="right"android:background="@drawable/circle_red"android:gravity="center"android:text="1"android:textColor="#fff"android:textSize="12sp"android:visibility="gone"/></FrameLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_margin="8dp"android:orientation="vertical"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center_vertical"android:background="@drawable/shape_background_solid"android:paddingLeft="4dp"android:paddingRight="4dp"android:text="品牌"android:textColor="@android:color/black"/><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginLeft="5dp"android:id="@+id/tv_title"android:layout_weight="1"android:singleLine="true"android:text="肯德基宅急送(信息路店)"android:textColor="#000"android:textSize="22sp"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center_vertical"android:paddingLeft="2dp"android:paddingRight="2dp"android:text="票"/></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginBottom="5dp"android:layout_marginTop="5dp"android:gravity="center_vertical"><RatingBarandroid:layout_width="wrap_content"android:layout_height="wrap_content"style="?android:attr/ratingBarStyleSmall"android:id="@+id/ratingBar"android:rating="2.8"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="5dp"android:layout_marginRight="5dp"android:text="2.8"android:textColor="#FFDE3D"android:textSize="12sp"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:id="@+id/tv_home_sale"android:text="月售243单"android:textSize="12sp"/></LinearLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:gravity="center_vertical"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:id="@+id/tv_home_send_price"android:layout_alignParentLeft="true"android:text="¥0起送/配送费 ¥9"android:textSize="12sp"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:id="@+id/tv_home_distance"android:layout_alignParentRight="true"android:text="556米/33分钟"android:textSize="12sp"/></RelativeLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="2dp"android:layout_marginBottom="5dp"android:layout_marginTop="10dp"android:background="#FFFFFF"/><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginBottom="5dp"android:layout_marginTop="5dp"android:background="#FFFFFF"><ImageViewandroid:layout_width="25dp"android:layout_height="25dp"android:layout_gravity="center_vertical"android:background="@drawable/jian"android:paddingLeft="2dp"android:paddingRight="2dp"android:text="减"android:textColor="#fff"/><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:text="在线支付满49元减10元,满89元减16元"android:textSize="12sp"android:layout_marginLeft="5dp"android:layout_gravity="center_vertical"/></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginBottom="5dp"android:layout_marginTop="5dp"android:gravity="center_vertical"><ImageViewandroid:layout_width="20dp"android:layout_height="20dp"android:layout_gravity="center_vertical"android:background="@drawable/zeng"android:paddingLeft="5dp"android:paddingRight="2dp"android:text="赠"android:textColor="#fff"/><TextViewandroid:layout_marginLeft="8dp"android:layout_width="match_parent"android:layout_height="wrap_content"android:text="满45元赠九珍果汁饮料"android:textSize="12sp"/></LinearLayout></LinearLayout></LinearLayout>

个人中心、登录界面

个人中心

class PeopleFragment : Fragment(){override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {val peopleview = View.inflate(activity, R.layout.fragment_people, null)val login = peopleview.find<ImageView>(R.id.image_login)login.setOnClickListener{val  intent = Intent(activity, LoginActivity::class.java)activity!!.startActivity(intent)}return peopleview}
}

个人中心跳转

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"xmlns:app="http://schemas.android.com/apk/res-auto"android:orientation="vertical"><ScrollViewandroid:layout_width="match_parent"android:layout_height="match_parent"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="vertical"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:background="#16A1E7"><com.makeramen.roundedimageview.RoundedImageViewapp:riv_oval="true"android:layout_width="80dp"android:layout_height="80dp"android:layout_gravity="center_vertical"android:layout_marginBottom="20dp"android:layout_marginLeft="15dp"android:layout_marginTop="25dp"android:src="@drawable/xxx"/><FrameLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:layout_gravity="center_vertical"android:layout_weight="1.0"android:layout_marginBottom="20dp"android:layout_marginLeft="10dp"android:layout_marginRight="15dp"android:layout_marginTop="20dp"><ImageViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:id="@+id/image_login"android:src="@drawable/login"/><LinearLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:id="@+id/ll_userinfo"android:gravity="center"android:visibility="invisible"android:orientation="vertical"android:layout_marginTop="10dp"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:id="@+id/username"android:text="username"android:textColor="#fff"android:textSize="18sp"/><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="horizontal"android:layout_gravity="center_vertical"></LinearLayout></LinearLayout></FrameLayout></LinearLayout></LinearLayout></ScrollView></LinearLayout>

登录界面

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"xmlns:app="http://schemas.android.com/apk/res-auto"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".ui.activity.LoginActivity"android:orientation="vertical"android:background="#EDEDEB"><RelativeLayout android:layout_width="match_parent" android:layout_height="0dp"android:layout_weight="1.2"android:orientation="horizontal"android:background="#3090E6"><ImageView android:layout_width="40dp" android:layout_height="40dp"android:id="@+id/iv_goback" android:src="@drawable/goback"android:layout_alignParentBottom="true" android:layout_marginLeft="20dp"/><TextView android:layout_width="wrap_content" android:layout_height="wrap_content"android:text="登陆" android:layout_toRightOf="@id/iv_goback" android:id="@+id/iv_text_login"android:textColor="#FFF" android:textSize="24sp" android:layout_alignParentBottom="true"android:layout_marginBottom="5dp" android:layout_marginLeft="15dp"/><TextView android:layout_width="wrap_content" android:layout_height="wrap_content"android:text="密码登陆" android:textSize="20sp" android:textColor="#FFF" android:layout_alignParentBottom="true"android:layout_alignParentRight="true" android:layout_marginBottom="7dp"/></RelativeLayout><RelativeLayout android:layout_width="match_parent" android:layout_height="0dp"android:layout_weight="8.5"><EditText android:layout_width="280dp" android:layout_height="wrap_content"android:id="@+id/iv_edit_phone" android:layout_marginTop="30dp"android:layout_marginLeft="20dp" android:hint="请输入手机号码"/><Button android:layout_width="wrap_content" android:layout_height="45dp"android:id="@+id/iv_btn_houqu" android:text="获取验证码" android:textColor="#FFF"android:background="#3090E6" android:layout_toRightOf="@id/iv_edit_phone"android:layout_marginTop="20dp" android:layout_marginLeft="10dp"/><EditText android:layout_width="100dp" android:layout_height="wrap_content"android:id="@+id/iv_edit_number" android:hint="验证码" android:layout_below="@id/iv_edit_phone"android:layout_marginLeft="20dp" android:layout_marginTop="10dp"/><Button android:layout_width="match_parent" android:layout_height="wrap_content"android:id="@+id/iv_btn_login" android:background="#33C937" android:text="登陆"android:layout_below="@id/iv_edit_number" android:layout_marginTop="50dp"android:textColor="#FFF" android:textSize="20sp"/><TextView android:layout_width="wrap_content" android:layout_height="wrap_content"android:id="@+id/texeView" android:text="第三方登录"android:layout_below="@id/iv_btn_login" android:layout_marginTop="100dp"android:textSize="20sp" android:layout_centerHorizontal="true"/><LinearLayout android:layout_width="360dp" android:layout_height="wrap_content"android:orientation="horizontal" android:layout_below="@id/texeView" android:id="@+id/iv_lin_image"android:layout_marginTop="30dp" android:layout_centerHorizontal="true"><ImageView android:layout_width="0dp" android:layout_weight="1" android:layout_height="50dp"android:src="@mipmap/weixin" android:id="@+id/iv_people_weixin" /><ImageView android:layout_width="0dp" android:layout_weight="1" android:layout_height="50dp"android:src="@mipmap/qq" android:id="@+id/iv_people_qq"/><ImageView android:layout_width="0dp" android:layout_weight="1" android:layout_height="50dp"android:src="@mipmap/weibo" android:id="@+id/iv_people_weibo"/><ImageView android:layout_width="0dp" android:layout_weight="1" android:layout_height="50dp"android:src="@mipmap/taobao" android:id="@+id/iv_people_taobao"/></LinearLayout><LinearLayout android:layout_width="360dp" android:layout_height="wrap_content"android:orientation="horizontal" android:layout_below="@id/iv_lin_image"android:layout_marginTop="5dp" android:layout_centerHorizontal="true"><TextView android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content"android:text="微信" android:textSize="20sp" android:gravity="center"/><TextView android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content"android:text="QQ" android:textSize="20sp" android:gravity="center"/><TextView android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content"android:text="微博" android:textSize="20sp" android:gravity="center"/><TextView android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content"android:text="淘宝" android:textSize="20sp" android:gravity="center"/></LinearLayout></RelativeLayout></LinearLayout>

效果展示



第二天 Kotlin 外卖 APP相关推荐

  1. 如果外卖APP想窃听我,有几个骚操作?

    人类总有一种控制欲. 比如Siri,可能就是为了满足人懒又喜欢场控设计的东西. 但如果手机里的APP脱离了控制,开始长耳朵听你说话了,人就慌得一批. 想象下,某天下班后饥肠辘辘的你向男/女朋友撒娇说想 ...

  2. 基于Android的外卖App系统设计

    基于Android的外卖App系统设计 摘要 随着智能手机的快速普及,智能手机操作系统市场风生水起.为了让智能手机用户能够随时随地查询互联网所提供的服务,一种高效的办法就是将应用系统的功能拓展到手机终 ...

  3. 项目:Vue.js高仿饿了吗外卖APP(一)

    Vue.js高仿饿了吗外卖APP核心知识 使用Vue.js作为项目的技术栈!这是目前最火的MVVM框架(之一),轻量.简洁.高效.数据驱动.组件化的优点,被大家称为"简单却不失优雅,小巧而不 ...

  4. vue外卖APP 商家主页面商品滑动代码编写

    vue外卖APP 商家主页面商品滑动代码编写 一.第一步 1.第一步首先构建主页面shop.vue,此时页面包括两部分,第一部分商家页面头部shopHeader,第二部分利用router-view为动 ...

  5. 外卖APP,别跟我谈什么用户粘度,他们有吗?

    作者:店小二(微信号:freemyself2) 目前各个外卖APP鏖战正欢,国庆前还有最多满20减10的优惠政策,价格上的大幅度补贴对于用户来说肯定是心花怒放了.但是对于外卖APP而言,短时间内价格上 ...

  6. 作业三——原型化系统——外卖app

    一.软件链接: 原型化系统--外卖app:  https://modao.cc/app/12tKVXzI3uEDhhFsJW7m7g7DzVSAJnQ 二.软件简介 本app是一款外卖软件,和市场上饿 ...

  7. App设计灵感之十二组精美的外卖App设计案例

    外卖 App 界面多以单色作为食品展示的背景色,目的在于突出食品,更好的吸引用户,让用户可以更快的做出选择. ① Sushi Apps Exploration by Azie Melasari ② R ...

  8. h5外卖源码php_校园食堂外卖APP走红 更多APP定制开发上一品威客网

    近日,西安一高校推出了一款校园食堂外卖APP走红网络.该APP涵盖学校食堂的所有饭菜,并可给该校的师生提供校园食堂饭菜外卖服务.饭菜价格与食堂统一,且仅供该校内的师生使用. 目前开发校园外卖订餐系统可 ...

  9. 简单Android app开发_如何简单快速开发外卖app?

    如何开发一个外卖app?app开发需要多少钱?随着美团.饿了么的外卖app的发展,对餐饮.生鲜果蔬.超市便利店行业来说,app成为必不可缺少的一部分.与其向第三方交纳一定不开发一个自己的外卖平台.也有 ...

最新文章

  1. 【收藏】基于QGIS的Google Earth Engine插件已发布
  2. 【遥感数字图像处理】基础知识:第四章 遥感图像辐射纠正
  3. php 开启fsockopen函数,巧用php的fsockopen函数
  4. chrome扩展之3:一步步跟我学开发一个表单填写扩展
  5. MAC地址和IP地址的关系
  6. 优达学城深度学习之七——TensorFlow卷积神经网络
  7. CentOS(rsync+crond实现定时备份)
  8. nginx中root和alias的区别
  9. 作为一个对电脑配置一概不知的人,怎样才能一步一步了解电脑构造并且由此来学会怎样自己配置电脑?
  10. 计算机无法安装网卡驱动,电脑经验遇到网卡驱动安装不上的问题,该如何解决呢?一起来看看...
  11. 蓝牙双模音频模块 BT401蓝牙BLE应用笔记
  12. 计算机服务无法启动,Win7系统下windows firewall服务无法启动怎么解决【图文】
  13. 二元函数可导与可微的关系_如何理解多元函数可微与可偏导的关系?
  14. 京东快运 | 快递单号查询API
  15. 史上最全的FreeIPA搭建教程(二)
  16. R语言绘图之ggplot2包
  17. 关于电影票对接公众号cps
  18. 产品运营常踩的七大坑,你踩过吗?
  19. ROS入门七 机器人建模——URDF
  20. python中and怎么计算_Python中 and,or 的计算规则

热门文章

  1. 手把手带你制作WIFI智能开关.走进物联网-ESP8266学习日记(三)
  2. 频谱仪的更改ip_IP3 三阶交调截取点测试(转帖)
  3. 分析拉卡拉支付的风控技术
  4. C++线程间共享数据
  5. RK3568-签批一体机-用户案例
  6. 过分了,别人用来做桌面应用开发,这家伙却用来撩妹(1)--上帝给你开一个窗口(Tkinter)
  7. CTB-Locker敲诈者病毒下载器分析
  8. 乐鑫Esp32学习之旅 24 分享在 esp32 SDK实现冷暖光色温RGB/HSV平滑调节的封装,轻松集成到您的项目去。(附带Demo)
  9. 什么是stl? 如何使用stl?
  10. 软件需求管理用例方法 pdf_演讲|软件造价联盟罗翔:业务分析与需求管理实践...