协调器布局重叠底部按钮
Coordinator Layout Overlapping Bottom Buttons
我正在设计我的 XML 并且最初有一个与操作工具栏重叠的协调器布局。我四处阅读,发现添加 app:layout_behavior="@string/appbar_scrolling_view_behavior 属性有助于解决此问题。
但是,在我的 XML 中,我仍然遇到协调器布局与预览屏幕底部按钮重叠的问题。我知道这些按钮实际上在 phone 本身上,但我仍然不明白为什么布局会延伸到这些项目上。看到下面与底部按钮重叠的图像,我不记得在引入协调器布局之前看到过这个:
<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:fitsSystemWindows="true"
到主要父级,主要是 android.support.design.widget.CoordinatorLayout 托管其余部分。
我正在设计我的 XML 并且最初有一个与操作工具栏重叠的协调器布局。我四处阅读,发现添加 app:layout_behavior="@string/appbar_scrolling_view_behavior 属性有助于解决此问题。
但是,在我的 XML 中,我仍然遇到协调器布局与预览屏幕底部按钮重叠的问题。我知道这些按钮实际上在 phone 本身上,但我仍然不明白为什么布局会延伸到这些项目上。看到下面与底部按钮重叠的图像,我不记得在引入协调器布局之前看到过这个:
<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:fitsSystemWindows="true"
到主要父级,主要是 android.support.design.widget.CoordinatorLayout 托管其余部分。