【发布时间】:2018-07-10 14:21:24
【问题描述】:
我已将 AppBarLayout 与 app:layout_collapseMode="pin" 叠加在内容 FrameLayout 上。但是当我在片段中滚动时,AppBarLayout 不会崩溃。
如何让 AppBarLayout 可折叠并覆盖 FrameLayout?
这是我当前的 xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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">
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:nestedScrollingEnabled="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinator"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
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:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_alignParentTop="true"
android:background="@android:color/transparent"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:elevation="0dp"
app:layout_collapseMode="pin">
<android.support.v7.widget.Toolbar
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"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|enterAlways"
android:id="@+id/toolbar"
style="?android:attr/toolbarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:minHeight="?attr/actionBarSize"
app:elevation="0dp"
app:popupTheme="@style/ToolbarStyle"
tools:ignore="NewApi"/>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
</RelativeLayout>
【问题讨论】:
标签: android collapse android-coordinatorlayout android-relativelayout android-appbarlayout