现在市面上又很多app都实现了上滑隐藏下拉呈现视图的功能,这样可以让用户有更多的空间去浏览内容,CoordinatorLayout与AppBarLayout的功能远不止这些,大家有时间可以去探究一下,这里我只实现了上述功能。
首先来看布局代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:theme="@style/ThemeOverlay.AppCo