RecyclerView 滑动上面的控件也跟着往上滑

这个人中暑了 2018-11-30 07:05:11

我想实现底下的RecyclerView滑动时,上面圈起来的部分也跟着滑动,该怎么做到呢?
请确认能行再回答.我已经试过很多方法了
...全文
1098 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
这个人中暑了 2018-12-22
  • 打赏
  • 举报
回复
谢谢各位的帮助,最后我是通过NestedScrollingParent实现了,因为我的RecyclerView是在ViewPager里的Fragment里的。
但也会遇到底部显示空白的Bug,解决方法可以参照我写的文章
https://blog.csdn.net/qq_36999309/article/details/85217103
春华-秋实 2018-12-21
  • 打赏
  • 举报
回复
coodinatorlayout实现就可以啊,https://www.jianshu.com/p/f09723b7e887/ 看看这个,对你有帮助
IT_MR_Jie 2018-12-07
  • 打赏
  • 举报
回复
将红色部分的布局用recyclerview的headerview实现就好了
键盘舞者113 2018-12-01
  • 打赏
  • 举报
回复
你这个效果很常见啊,要通过CoordinatorLayout实现,

<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>

.


</android.support.design.widget.AppBarLayout>

<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="15dp"
android:src="@drawable/add_2"/>

</android.support.design.widget.CoordinatorLayout>

80,471

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧