android - 在 Android 布局底部添加工具栏时滚动行为不起作用

标签 android android-layout android-coordinatorlayout

我必须根据设计在屏幕底部添加一个工具栏。如果我删除协调器内的相对布局,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>

关于android - 在 Android 布局底部添加工具栏时滚动行为不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35055868/

相关文章:

android - 相对布局未低于定义

Android布局: Stick one Layout to the top of the screen and place another Layout centred below

android - 如何创建与 CoordinatorLayout 内容重叠的 AppBarLayout

java - Android arraylist 因迭代而崩溃

java - 冲突的内容提供者

android - Chromium WebView : "CheckMediaAccessPermission: Not supported" 内的 WebRTC 错误

android - android 向上滚动时自动隐藏或显示工具栏

android - 如何禁用 Android 上的授权弹出窗口?

android - iOS:类似 Android 布局的相对定位

android - CoordinatorLayout 在滚动端折叠或展开 AppBar