android 折叠与展开,android – 如何根据滚动方向折叠/展开视图?

您必须将协调器布局与CollapsingToolbarLayout一起使用

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:clipToPadding="false">

android:id="@+id/app_bar_layout"

android:layout_width="match_parent"

android:layout_height="210dp"

android:stateListAnimator="@animator/appbar_always_elevated" //I put this here because I want to have shadow when is open,but you have to create the xml file.

android:background="@color/WHITE">

android:id="@+id/collapsing_toolbar_layout"

android:layout_width="match_parent"

android:layout_height="match_parent"

app:collapsedTitleTextAppearance="@style/TextAppearance.AppCompat.Widget.ActionBar.Title.Inverse"

app:expandedTitleMarginStart="72dp"

app:expandedTitleTextAppearance="@style/TextAppearance.AppCompat.Widget.ActionBar.Title.Inverse"

app:layout_scrollFlags="scroll|exitUntilCollapsed"> //HERE you should take a look what you want your collapse bar do.

android:id="@+id/app_bar"

android:layout_width="match_parent"

android:layout_height="40dp"

app:layout_collapseMode="pin" />

android:id="@+id/main_home_list_swipe"

android:layout_width="match_parent"

android:layout_height="match_parent"

app:layout_behavior="@string/appbar_scrolling_view_behavior" >

android:id="@+id/main_home_list"

android:layout_width="match_parent"

android:layout_height="match_parent"/>

Obs:如果您放入xml文件,注释将给出错误.提议,所以你会记得读哈哈哈

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值