android顶部折叠组件,android 顶部悬停折叠CoordinatorLayout,AppBarLayout

MaterialDesign5.0 中 CoordinatorLayout 和 AppBarLayoutjava

来制做悬停效果布局 。android

先看下栗子app

7c5b8394c023e16e78023d3b9967e9cd.png

实现很简单 布局

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"

android:orientation="vertical"

tools:context="com.example.administrator.exampletest.MainActivity">

android:layout_width="match_parent"

android:layout_height="match_parent">

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:fitsSystemWindows="true"

>

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:orientation="vertical"

app:layout_scrollFlags="scroll"

>

android:src="@mipmap/ic_launcher_round"

android:layout_width="wrap_content"

android:layout_height="25dp" />

android:src="@mipmap/ic_launcher_round"

android:layout_width="wrap_content"

android:layout_height="25dp" />

android:src="@mipmap/ic_launcher_round"

android:layout_width="wrap_content"

android:layout_height="25dp" />

android:layout_width="match_parent"

android:layout_height="0.5dp"

android:background="#f0f"

app:layout_scrollFlags="scroll"

>

android:background="#a3e2f6"

android:text="我是悬停的那个控件哦"

android:gravity="center"

android:layout_margin="10dp"

android:layout_width="match_parent"

android:layout_height="20dp" />

android:id="@+id/rv"

android:layout_width="match_parent"

android:layout_height="match_parent"

app:layout_behavior="@string/appbar_scrolling_view_behavior"

>

布局文件使用spa

CoordinatorLayout

标明内部须要监听事件.net

AppBarLayout

标记须要折叠的布局  code

在须要折叠布局中 标注xml

app:layout_scrollFlags="scroll"

须要在顶部停留的控件  就直接写就好了。blog

在须要监听滑动触发折叠的控件上 标注事件

app:layout_behavior="@string/appbar_scrolling_view_behavior"

简单实现就酱紫

小栗子

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值