协调器布局重叠底部按钮

问题描述 投票:3回答:2

我正在设计我的XML,并且最初有一个与Action ToolBar重叠的Coordinator Layout。我阅读并发现添加应用程序:layout_behavior =“@ string / appbar_scrolling_view_behavior属性有助于解决此问题。

但是,在我的XML中,我仍然遇到协调器布局与预览屏幕上的底部按钮重叠的问题。我知道这些按钮实际上是在手机上,但我仍然感到困惑,为什么布局扩展到这些项目。看下面的图像与底部按钮重叠,我不记得在引入协调器布局之前看到这个:

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />

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


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="2.2" />

    <LinearLayout
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:layout_width="match_parent"
        android:orientation="vertical"
        android:layout_height="0dp"
        android:layout_weight="2">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
             />

        <CheckBox
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
             />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1.3">

    </LinearLayout>

</LinearLayout>

See the Layout overlapping the buttons

android xml android-coordinatorlayout
2个回答
5
投票

当您添加app:layout_behavior="@string/appbar_scrolling_view_behavior"它基本上做的是它在Toolbar下面设置该布局并将布局放入ScrollView类的东西。因为在那个布局之上有一个Toolbar,所以整个布局(形成的ScrollView)被Toolbar的高度向下推。


0
投票

有类似的问题通过添加解决了它

 android:fitsSystemWindows="true"

到主要的父母,主要是android.support.design.widget.CoordinatorLayout,主持其余的。

© www.soinside.com 2019 - 2024. All rights reserved.