在 Android 中将工具栏添加到布局底部时,滚动行为不起作用



我必须根据设计在屏幕底部添加一个工具栏。如果我删除协调器内部的相对布局,app:layout_scrollFlags="scroll|enterAlways"工作正常。

但是如果没有这个相对布局,我无法在屏幕底部设置工具栏!

如何通过更改以下布局来管理底部工具栏和顶部工具栏隐藏功能?

<android.support.design.widget.CoordinatorLayout 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">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <android.support.design.widget.AppBarLayout
            android:id="@+id/appBarLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:layout_gravity="bottom"
                android:background="?attr/colorPrimary"
                app:layout_scrollFlags="scroll|enterAlways"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

            <android.support.design.widget.TabLayout
                android:id="@+id/tabLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/toolbar"
                android:background="@color/tab_color" />

        </android.support.design.widget.AppBarLayout>
        <include
            layout="@layout/inc_bottom_toolbar_with_menu"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true" />
        <android.support.v4.view.ViewPager
            android:id="@+id/viewPager"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_above="@+id/bottomToolBar"
            android:layout_below="@id/appBarLayout"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />

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

PS :我已经删除了图像,因为我的TL坚持这样做。

<RelativeLayout
  android:layout_width="match_parent"
  android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout>
      -----------------------
</android.support.design.widget.CoordinatorLayout>
<!-- bottom contents here --->
</RelativeLayout>

最新更新