2015-10-15 30 views
0

我正在嘗試使用androids CoordinatorLayout和FrameLayout。我想有是顯示一些信息 tablayout 列表視圖爲包含AppbBarLayout的活動設置背景

當列表視圖,滾動工具欄和LinearLayouts應該scrollup和隱藏和標籤應在頂部走 工具欄 的LinearLayout。

我有型的佈局:

<android.support.v4.widget.DrawerLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true"> 

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

     <android.support.design.widget.AppBarLayout 
       android:id="@+id/appbar" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"> 

     <-- stuff I want to hide on scrolling --> 
      <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        app:layout_scrollFlags="scroll|enterAlways" 
        android:orientation="vertical"> 

       <include 
         layout="@layout/toolbar" 
         app:layout_scrollFlags="scroll|enterAlways"/> 

       <LinearLayout 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         app:layout_scrollFlags="scroll|enterAlways" 
         android:orientation="vertical"> 
        <TextView 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:text="Gamercard content" 
          /> 
        <TextView 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:text="More Gamercard content" 
          /> 
       </LinearLayout> 

      </LinearLayout> 

      <-- stuff I dont want to hide on scrolling --> 

      <android.support.design.widget.TabLayout 
        android:id="@+id/tabLayout" 
        android:scrollbars="horizontal" 
        android:layout_below="@+id/toolbar" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"/> 


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

     <!-- My Scrollable View --> 
     <include layout="@layout/nested_scrolling_container_view"/> 

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

</android.support.v4.widget.DrawerLayout> 

我想要做的是有一個圖片作爲背景的整個活動,但我看到的是,AppBarLayout部分總是黑暗。請幫忙。

回答

0

我可以以編程方式將代碼中的backgroundColor設置爲Color.TRANSPARENT。

appbar.setBackgroundColor(Color.TRANSPARENT);