Android list列表滑动显示隐藏toolbar(RecyleView)

来源:互联网 发布:数控车床编程基础视频 编辑:程序博客网 时间:2024/05/16 15:01

在之前一篇博客中,讨论了Android list列表滑动显示隐藏toolbar(listview),实现是google plus的效果。

如果想要类似google photos的效果,更简单:

只要在ToolBar里增加一句就可以:

app:layout_scrollFlags="scroll|enterAlways|snap"

<?xml version="1.0" encoding="utf-8"?><android.support.design.widget.CoordinatorLayout    xmlns:android="http://schemas.android.com/apk/res/android"    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"    tools:context="com.science.test.MainActivity">    <android.support.design.widget.AppBarLayout        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:theme="@style/AppTheme.AppBarOverlay">        <android.support.v7.widget.Toolbar            android:id="@+id/toolbar"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:fitsSystemWindows="true"            app:layout_scrollFlags="scroll|enterAlways|snap"            android:background="?attr/colorPrimary"            app:popupTheme="@style/AppTheme.PopupOverlay"/>    </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="bottom|end"        android:layout_margin="@dimen/fab_margin"        android:src="@android:drawable/ic_dialog_email"/></android.support.design.widget.CoordinatorLayout>

0 0
原创粉丝点击