2017-06-17 107 views
0

我正在使用這種佈局來加載片段,但是當我在設備上運行時,它看起來像這樣。座標佈局重疊容器

enter image description here

下面是我code.Any說明爲什麼FrameLayout裏是重疊的協調佈局。 感謝您的幫助:)

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:elevation="7dp"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <android.support.design.widget.CoordinatorLayout xmlns:app="http://schemas.android.com/apk/res-auto" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:id="@+id/cl_root_inner_main" 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/toolbar_height" 
     android:fitsSystemWindows="true"> 

     <android.support.design.widget.AppBarLayout 
      android:id="@+id/tool_rl" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:theme="@style/AppTheme.AppBarOverlay"> 

      <android.support.v7.widget.Toolbar xmlns:app="http://schemas.android.com/apk/res-auto" 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:background="@color/colorPrimary" 
       android:titleTextColor="@color/white" 
       app:popupTheme="@style/AppTheme.PopupOverlay"> 

       <RelativeLayout 
        android:id="@+id/buttonsview" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"> 


        <ImageView 
         android:id="@+id/btnBack" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_alignParentStart="true" 
         android:layout_centerVertical="true" 
         android:padding="@dimen/x10" 
         android:src="@drawable/ic_arrow_back" /> 


        <TextView 
         android:id="@+id/fragtitle" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerHorizontal="true" 
         android:layout_centerVertical="true" 
         android:text="@string/select_district" 
         android:textColor="@color/white" 
         android:textSize="20sp" 
         android:visibility="invisible" /> 

        <Button 
         android:id="@+id/btnPost" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_alignParentStart="true" 
         android:layout_centerVertical="true" 
         android:layout_marginEnd="@dimen/x10" 
         android:layout_gravity="center_horizontal" 
         android:text="@string/post" 
         android:textColor="@color/white" 
         android:textSize="12sp" 
         android:theme="@style/blue_button" /> 

       </RelativeLayout> 


      </android.support.v7.widget.Toolbar> 
     </android.support.design.widget.AppBarLayout> 
    </android.support.design.widget.CoordinatorLayout> 


    <FrameLayout 
     android:id="@+id/container" 
     android:background="@color/orange" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 
</LinearLayout> 

回答

0

此使用協調佈局是一個xml,我認爲這將有助於你

<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" 
    android:fitsSystemWindows="true" 
    tools:context="com.software.products.ui.activity.ToolbarUsedActivity" 
    android:layoutDirection="rtl"> 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <--!just use toolbar here--> 

     <com.software.android.view.ddToolbar 
      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_main2" /> 

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