2017-06-02 96 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>