扒一扒app

起因是这样的,拿到一个产品需求,ui如下,具体交互细节呢,美工小姐姐在设计稿上标了一小行字:去看看每日优鲜。既然如此,那就先看看别人家是怎么做的吧。
在这里插入图片描述

1.工具篇:

先参考文章:查看布局

  1. 先找到android sdk 的目录-》tools -》monitor.bat. 启动。(我的是在此目录下,你的不一定哦-)
    在这里插入图片描述
  2. 按照如下操作,之后就获取到别人app的布局视图了
    在这里插入图片描述
  3. 选取其中某个交互开始分析:
    打开app,在此分类界面,一只手不停下拉,不松手,另外一只手按照上面的步骤进行操作,获取到的截图如下:
    在这里插入图片描述
    看看红框我们能分析出哪些信息:
    ① 布局是ViewGroup,可以下拉刷新,上拉加载更多,结合resource-id:srl-produce_classify,是不是有点熟悉了,大胆猜测,极有可能用的是SmartRefreshLayout,因为它正好是ViewGroup。这里的header需要自定义了。官网也告诉了如何自定义,参考即可。
    ②红色部分往上滑的时候,图片区域是要被滑出屏幕的,然后是综合,销量的布局置顶不再滑动,之后才是下面recycleview的滑动,结合右边来看,最外层用的是NestedScrollView(根据id来的),第一个子view是LinearLayout,第二个子view是viewgroup,因为要处理滑动事件,我们熟悉的CoordinatorLayout就是一个ViewGroup,它可以帮我们处理滑动事件,那么不妨猜测第二个子view用的就是此布局了。
    在这里插入图片描述

2. 实践篇

貌似我们已经分析得差不多了,那么开始实践上手验证下我们的猜想:

  1. 布局方式:
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    android:background="#ffffff"
    >

    <TextView
        android:id="@+id/tvSearch"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:text="搜索"
        app:layout_constraintTop_toTopOf="parent"
        android:textColor="@color/black"
        android:textSize="20sp"
        android:gravity="center"
        />


    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/rvLeft"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintHorizontal_weight="1"
        app:layout_constraintVertical_weight="1"
        app:layout_constraintTop_toBottomOf="@+id/tvSearch"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toLeftOf="@+id/clRight"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        android:orientation="vertical"
        tools:listitem="@layout/item_test"
        />

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:id="@+id/clRight"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintHorizontal_weight="3"
        app:layout_constraintVertical_weight="1"
        app:layout_constraintTop_toBottomOf="@+id/tvSearch"
        app:layout_constraintLeft_toRightOf="@+id/rvLeft"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        >


        <com.google.android.material.appbar.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            >

            
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值