<...">

AppBarLayout overlaps ConstraintLayout

I have AppBarLayout

nested insideCoordinatorLayout

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.michael.blemanager.Activities.ColorPickerActivity.Color1">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appBar"
        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>

    <include layout="@layout/content_color1"/>

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

      

Here is the provided layout content_color1

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.example.michael.blemanager.Activities.ColorPickerActivity.Color1"
    tools:showIn="@layout/activity_color1">

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@color/default_background"
        >

        /....

    </LinearLayout>

</android.support.constraint.ConstraintLayout>

      

Now AppBarLayout

overlaps for some reasonConstraintLayout

See where the toolbar overlaps the color circle? How to prevent overlap?

enter image description here

+3


source to share


2 answers


Wrap your include tag inside FrameLayout

with layout_behavior

of appbar_scrolling_view_behavior

like this:



<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <include layout="@layout/content_color1"/>
</FrameLayout>

      

+1


source


Change CoordinatorLayout to ConstraintLayout.



I had the same problem and it worked for me.

-1


source







All Articles