我正在设计我的 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>
最佳答案
当您添加 app:layout_behavior="@string/appbar_scrolling_view_behavior"
时,它基本上所做的是将该布局设置在 Toolbar
下方,并将这两个布局放入 ScrollView之类的事情。由于该布局顶部有一个 Toolbar
,因此整个布局(形成的 ScrollView)被 Toolbar
的高度向下推。
关于android - 协调器布局重叠底部按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34751424/