代码拉取完成,页面将自动刷新
前言,一天在点外卖的时候,注意到饿了么列表页的滑动效果不错,但是觉得其中的手势滑动还是挺复杂的,正好又碰到了在熟悉Touch事件的理解当中,所以就抽空对着饿了么的列表页面尝试写写这个效果,同时增加了双列表的联动效果
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
dependencies {
com.github.WelliJohn:StickScrollView:1.1.6
}
<wellijohn.org.scrollviewwithstickheader.ScrollViewWithStickHeader
android:id="@+id/stick_scroll_view"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/ll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"
android:focusableInTouchMode="true"
android:orientation="vertical">
//这里是header部分,可以随便自定义
</LinearLayout>
<LinearLayout
android:id="@+id/ll_stick_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.TabLayout
android:id="@+id/order_manager_tabs"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#FFFFFF"
tools:tabGravity="fill"
tools:tabMode="fixed" />
<android.support.v4.view.ViewPager
android:id="@+id/vp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</wellijohn.org.scrollviewwithstickheader.ScrollViewWithStickHeader>
比如我们看到的仿饿了么的列表页界面,我们就需要在ViewPager设置Fragment,fragment中是左右两个列表,看下fragment的xml设置:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<wellijohn.org.scrollviewwithstickheader.ChildRecyclerView
android:id="@+id/child_recyclerview"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#EEEEEE" />
<wellijohn.org.scrollviewwithstickheader.ChildRecyclerView//LinearLayoutManager需要继承NoSlideLinearLayoutManager,GridLayoutManager需要继承NoSlideGridLayoutManager。
android:id="@+id/child_recyclerview_right"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:layout_weight="3" />
</LinearLayout>
mStickScrollView.setContentView(mLLStickList);//这个是必须的,mLLStickList就是你想到这个布局再滑动就是下面列表滑动的部分了。
mStickScrollView.setSuspensionView(mViewBottom);//这个是底部的悬浮布局,如果没有可以不设置
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型