android - 协调器布局重叠底部按钮

标签 android xml android-coordinatorlayout

我正在设计我的 XML,最初有一个与操作工具栏重叠的协调器布局。我四处阅读,发现添加 app: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

最佳答案

当您添加 app:layout_behavior="@string/appbar_scrolling_view_behavior" 时,它基本上所做的是将该布局设置在 Toolbar 下方,并将这两个布局放入 ScrollView之类的事情。由于该布局顶部有一个 Toolbar,因此整个布局(形成的 ScrollView)被 Toolbar 的高度向下推。

关于android - 协调器布局重叠底部按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34751424/

相关文章:

android - 开始新 Activity 时强制关闭

android - 适用于 Android 的 PyQt5 GUI 与 Kivy GUI

java - jsp中如何避免检查null

带有折叠工具栏的 RecyclerView 中的 Android 字母快速 ScrollView

android - 如何获取 firebase 库,例如firebase-messaging-9.4.0.jar

android - 更新 firebase 版本后出现错误 "Cannot resolve symbol R"

Python 在没有第三方库的情况下操作和保存 XML

java - 通过 JAXB 为枚举提供自定义值序列化

android - CoordinatorLayout的 'keyline' LayoutParams怎么用?

android - AppBarLayout 在 Toolbar 下方滚动内容