2017-06-02 155 views
2

我有嵌套在CoordinatorLayoutAppBarLayout重疊ConstraintLayout

<?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> 

這裏的內部的AppBarLayout中所包含的佈局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> 

現在由於某種原因AppBarLayout重疊ConstraintLayout

看到工具欄與彩色圓圈重疊?我如何防止重疊?

enter image description here

回答

-1

變化CoordinatorLayout到ConstraintLayout。

我有同樣的問題,併爲我工作。

1

包住包括使用的appbar_scrolling_view_behaviorlayout_behavior一個FrameLayout內標籤是這樣的:

<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>