Android之CoordinatorLayout+AppBarLayout顶部折叠栏

我的是androidX

添加依赖

  implementation 'com.google.android.material:material:1.0.0'implementation 'androidx.recyclerview:recyclerview:1.0.0'

与之前不同的是

Recycleview里面的是这个:app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"

大概写个结构:

 <com.google.android.material.appbar.AppBarLayout<com.google.android.material.appbar.AppBarLayout//这个button可以折叠<Button  app:layout_scrollFlags="scroll|enterAlways"></com.google.android.material.appbar.AppBarLayout>//列表<androidx.recyclerview.widget.RecyclerView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

下面是全部代码,放到一个布局里面就行

<androidx.coordinatorlayout.widget.CoordinatorLayoutandroid:layout_width="match_parent"android:layout_height="match_parent">这个view的子view,有app:layout_scrollFlags="scroll|enterAlways"就可以折叠<com.google.android.material.appbar.AppBarLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"><!--这个继承了,所以这里面的都会被折叠--><LinearLayoutapp:layout_scrollFlags="scroll|enterAlways"android:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="vertical"android:gravity="center_vertical"><Buttonandroid:text="aaa"android:layout_width="match_parent"android:layout_height="wrap_content" /><Buttonapp:layout_scrollFlags="scroll|enterAlways"android:text="ccc"android:layout_width="match_parent"android:layout_height="wrap_content" /><Buttonapp:layout_scrollFlags="scroll|enterAlways"android:text="ddd"android:layout_width="match_parent"android:layout_height="wrap_content" /><Buttonapp:layout_scrollFlags="scroll|enterAlways"android:text="bbb"android:layout_width="match_parent"android:layout_height="wrap_content" /></LinearLayout><!--这是一个不会动的标题栏--><androidx.appcompat.widget.Toolbarandroid:layout_width="match_parent"android:layout_height="50dp"></androidx.appcompat.widget.Toolbar></com.google.android.material.appbar.AppBarLayout><!--RecyclerView的列表--><!--AndroidX要使用:app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"才行--><androidx.recyclerview.widget.RecyclerViewapp:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"android:id="@+id/recycler_view"android:layout_width="match_parent"android:layout_height="match_parent"/></androidx.coordinatorlayout.widget.CoordinatorLayout>

AndroidX之CoordinatorLayout+AppBarLayout顶部折叠栏相关推荐

  1. CoordinatorLayout+AppBarLayout顶部栏吸顶效果

    看需求/效果 如果要实现如下效果,顶部标题栏随着上滑隐藏,且能显示缩略文字标题,那么就要用到CoordinatorLayout+几个layout了. 控件简介 CoordinatorLayout遵循M ...

  2. Androidx CoordinatorLayout 和 AppBarLayout 实现折叠效果(通俗的说是粘性头效果)

    Androidx  CoordinatorLayout 和 AppBarLayout 实现折叠效果 或者 说是粘性头效果 先看下面是不是你需要的结果  大致顺序是先滚动整体,然后折叠 在滚动list ...

  3. CoordinatorLayout中AppBarLayout的折叠仅依靠滑动RecyclerView实现

    直接上效果图,如果不做处理,CoordinatorLayout中的AppBarLayout可以滑动折叠. 我们希望达到如下的效果,即AppBarLayout的折叠仅依靠滑动RecyclerView实现 ...

  4. android开发(49) android 使用 CollapsingToolbarLayout ,可折叠的顶部导航栏

    概述 在很app上都见过 可折叠的顶部导航栏效果.google support v7  提供了 CollapsingToolbarLayout 可以实现这个效果.效果图如下:    实现步骤 1. 写 ...

  5. CoordinatorLayout/AppbarLayout/CollapsingToolbarLayout的配合使用,Toolbar特效

    上面这个特效就是Toolbar与CoordinatorLayout/AppbarLayout/CollapsingToolbarLayout配合后的效果:这几个View单独使用没什么效果,一般都是要互 ...

  6. Meterial Design最佳体验(1): 使用Toolbar, CoordinatorLayout, AppBarLayout等实现精美标题栏

                          Meterial Design最佳体验(1): 使用Toolbar, CoordinatorLayout, AppBarLayout等实现精美标题栏   作 ...

  7. coordinatorlayout_一篇文章学会Coordinatorlayout+AppbarLayout

    点击上方蓝字关注 ?? 来源:  奔跑吧李博 https://www.jianshu.com/p/cd93da2b7a24 前言 现如今,折叠式布局在App中相当常见,给人一种科技感,充满良好的用户体 ...

  8. SwipeRefreshLayout+CoordinatorLayout+AppBarLayout+TabLayout+ViewPager+RecyclerView 刷新,不能滑动等问题

    使用SwipeRefreshLayout+CoordinatorLayout+AppBarLayout+TabLayout+ViewPager+Fragment+RecyclerView 实现首页悬浮 ...

  9. Android CoordinatorLayout 实现浮动导航栏效果、常规用法

    CoordinatorLayout Android CoordinatorLayout+RecyclerView Demo Android CoordinatorLayout+AppBarLayout ...

最新文章

  1. 两个网站做到同一个服务器,两个网站放在同一个服务器 备案
  2. 怎样下载python模块sublime text3中_Python3.7.3安装教程并集成Sublime Text3
  3. 蓝桥杯 ALGO-31 算法训练 开心的金明
  4. 总结 创建领取 微信会员卡 踩过的坑
  5. linux oracle删除恢复数据恢复,Linux下Oracle误删除数据文件恢复操作
  6. js 获取当前日期,并设置成指定格式
  7. load,initialize方法
  8. HTML5(FileRdeader)
  9. python中出现nameerror_python类中出现NameError的问题
  10. 从条件概率到贝叶斯公式
  11. JavaScript将小写金额转换成大写
  12. Vb自动读取本地HTML,VB读取网页内容 方法汇总 - mystic的个人空间 - 51Testing软件测试网 51Testing软件测试网-软件测试人的精神家园...
  13. 最好用的WIN7WIN10激活工具
  14. MFC中Combo控件的使用
  15. kali虚拟机无法发现外置网卡问题
  16. boot bios傻傻分不清
  17. 确认main_arena相对libc的偏移地址
  18. 支付宝集福攻略,作为程序员的你集福了么?
  19. WebStrom代码中出现浅黄色背景
  20. linux网站ip访问量查询,如何统计网站每天PV和IP访问量排行

热门文章

  1. 2021高考成绩查询电话号码多少,重庆高考成绩查询电话号码多少,2021年重庆高考查分电话...
  2. ubntu18.04下载wps
  3. 机器人工程毕业设计☞外文翻译
  4. 吴昊品游戏核心算法 Round 16 —— 吴昊教你玩口袋妖怪 第十弹 超能力系道馆
  5. 程序 = 数据结构 + 算法
  6. 初次使用RTL8710AF开发板的一些心得
  7. python困惑:unix(LF)和windows(CR LF)
  8. 值得买的android手机,最值得购买的安卓手机有哪些?这几款很不错,可以了解一下...
  9. HCIA | WLAN二层旁挂组网实验
  10. Android权限设置大全