2016-04-16 21 views
0

我有一個根的CoordinatorLayout,它有AppBarLayout,它包含一個LinearLayout,它有2個LinearLayout作爲子項。我們稱這些子佈局爲A和B.我無法同時顯示A和B的內容。 A節目和B節目的內容沒有,當我刪除A的內容時只有B節目的內容反之亦然。這就是當我在LinearLayout容器中包含A和B的內容時的樣子。CoordinatorLayout無法正常使用2個子佈局

enter image description here

A和B都具有Textviews但只有的節目的TextView和B沒有。

這裏的佈局的代碼:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/main_content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true"> 
    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fitsSystemWindows="true" 
     android:theme="@style/Theme.AppCompat.Light.NoActionBar"> 
     <LinearLayout 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="#ffff" 
      android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed" 
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light"> 
      <LinearLayout 
       android:orientation="vertical" 
       android:minWidth="25px" 
       android:minHeight="25px" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:id="@+id/A" 
       android:padding="10dp"> 
       <TextView 
        android:text="Large Text" 
        android:textAppearance="?android:attr/textAppearanceLarge" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:id="@+id/title" 
        android:textColor="#000000" 
        android:fontFamily="sans-serif-light" /> 
      </LinearLayout> 
      <LinearLayout 
       android:orientation="horizontal" 
       android:minWidth="25px" 
       android:minHeight="25px" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:id="@+id/B" 
       android:background="@drawable/border" 
       android:padding="10dp"> 
       <TextView 
        android:text="Large Text" 
        android:textAppearance="?android:attr/textAppearanceLarge" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:id="@+id/textview" 
        android:textColor="#000000" 
        android:fontFamily="sans-serif-light" /> 
      </LinearLayout> 
     </LinearLayout> 
    </android.support.design.widget.AppBarLayout> 
    <android.support.v7.widget.RecyclerView 
     android:id="@+id/rv" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 
</android.support.design.widget.CoordinatorLayout> 

我已經嘗試了一切,但我無法弄清楚什麼是錯的。滾動行爲正常,但我看不到A和B的內容。 任何人都可以幫忙嗎?

回答

0

我通過使用FrameLayout而不是Linearlayout作爲A和B的容器來解決此問題。

相關問題