I am designing my XML and originally had a Coordinator Layout that was overlapping the Action ToolBar. I read around and found out taht adding the app:layout_behavior="@string/appbar_scrolling_view_behavior attribute helps resolve this issue.
However, in my XML I am still having an issue with the Coordinator Layout overlapping the bottom buttons on the Preview screen. I know these buttons are actually on the phone itself, but I am still puzzled why the layout is extending onto these items. See the below images overlapping the bottom buttons, I don't ever recall seeing this before the introduction of the Coordinator Layout:
<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>
When you add app:layout_behavior="@string/appbar_scrolling_view_behavior"
what it basically does is it sets that layout below the Toolbar
and puts both the layout into a ScrollView kind of thing. Since there's a Toolbar
on top of that layout hence, that entire layout (ScrollView that is formed) is pushed down by the height of the Toolbar
.
Had similar problem solved it by adding
android:fitsSystemWindows="true"
to the main parent which is mostly the android.support.design.widget.CoordinatorLayout that host the rest.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.