使用AppBar创建CoordinatorLayot从底部展开

时间:2018-10-10 19:00:03

标签: android android-coordinatorlayout coordinator-layout

我如何做到这一点:

enter image description here

但从底部扩展 ??? 我尝试过BottomSheetBehavior,但是BottomSheet覆盖了内容。

1 个答案:

答案 0 :(得分:0)

您可以尝试一下。看起来像CollapasingToolbarLayout

<?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"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/toolbar_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"> // added this

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize" />

        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_scrolling" /> // your content

</android.support.design.widget.CoordinatorLayout>

在此处检查示例: http://saulmm.github.io/mastering-coordinator