2016-07-10 7 views
1

ツールバーは内容がで、LinearLayoutを含んでおり、LinearLayoutにフレーム&が含まれています。 なぜですか?ツールバーは、フラグメントを含むコンテンツ(LinearLayout)と重複します

私は参照用画像を追加午前5

<?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" 
    android:fitsSystemWindows="true" 
    tools:context="com.example.popularmovies2.MainActivity"> 

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

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

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

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:baselineAligned="false" 
     android:divider="?android:attr/dividerHorizontal" 
     android:orientation="horizontal" 
     tools:context="com.example.popularmovies2.MainActivity"> 

     <fragment 
      android:id="@+id/fragment" 
      android:name="com.example.popularmovies2.MainActivityFragment" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="2" 
      tools:layout="@android:layout/list_content" /> 

     <FrameLayout 
      android:id="@+id/movie_detail_fragment" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="4" /> 

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

のAndroid Studioの2.2のプレビューを使用しています。親切に見て&ガイドを持っています。 CoordinatorLayoutがでframeLayoutのような役割を果たし

image

答えて

12

。それはその子供たちを覆います。 AppBarLayoutとLinearLayoutを次のような別の垂直線形レイアウトでラップします。

<?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" 
    android:fitsSystemWindows="true" 
    tools:context="com.example.popularmovies2.MainActivity"> 

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

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

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

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

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:baselineAligned="false" 
     android:divider="?android:attr/dividerHorizontal" 
     android:orientation="horizontal" 
     tools:context="com.example.popularmovies2.MainActivity"> 

     <fragment 
      android:id="@+id/fragment" 
      android:name="com.example.popularmovies2.MainActivityFragment" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="2" 
      tools:layout="@android:layout/list_content" /> 

     <FrameLayout 
      android:id="@+id/movie_detail_fragment" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="4" /> 

    </LinearLayout> 
</LinearLayout> 
</android.support.design.widget.CoordinatorLayout> 
+0

ありがとうございました。出来た。 –

関連する問題