0

我的主佈局有一個CoordinatorLayout,它有一個AppBarLayout,CollapsingToolbarLayout,Toolbar和一個TabLayoutAndroid工具欄沒有海拔

但是,工具欄不顯示陰影。

這是我的佈局:

<android.support.v4.widget.DrawerLayout 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:layout_gravity="right" 
    android:focusableInTouchMode="true" 
    android:clickable="true" 
    android:layoutDirection="rtl" 
    android:fitsSystemWindows="true" 
    android:id="@+id/drawer_layout"> 
    <android.support.design.widget.CoordinatorLayout 
     android:id="@+id/mainCoordinatorLayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true" 
     android:layoutDirection="rtl" 
     android:background="#eeeeee" 
     android:clickable="true"> 
     <android.support.design.widget.AppBarLayout 
      android:layout_height="wrap_content" 
      android:layout_width="match_parent" 
      android:fitsSystemWindows="true" 
      app:layout_behavior="torathamachane.DisableableAppBarLayoutBehavior" 
      android:id="@+id/toolbar_layout"> 
      <android.support.design.widget.CollapsingToolbarLayout 
       android:id="@+id/collapsing_toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="200dp" 
       android:fitsSystemWindows="true" 
       app:contentInsetStartWithNavigation="0dp" 
       app:layout_scrollFlags="scroll|exitUntilCollapsed" 
       app:contentScrim="?attr/colorPrimary" 
       app:collapsedTitleGravity="right|top" 
       app:expandedTitleGravity="bottom|right" 
       app:expandedTitleMarginBottom="44dp" 
       app:collapsedTitleTextAppearance="@style/CollapsedTitleTextAppearance" 
       app:expandedTitleTextAppearance="@style/ExpandedTitleTextAppearance" 
       app:expandedTitleMarginEnd="0dp" 
       app:expandedTitleMarginStart="30dp"> 
       <ImageView 
        android:id="@+id/headerImage" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:scaleType="centerCrop" 
        android:fitsSystemWindows="true" /> 
       <View 
        android:fitsSystemWindows="true" 
        android:layout_width="match_parent" 
        android:layout_height="100dp" 
        android:background="@drawable/scrim_top" 
        app:layout_collapseMode="pin" /> 
       <View 
        android:fitsSystemWindows="true" 
        android:layout_width="match_parent" 
        android:layout_height="112dp" 
        android:layout_gravity="bottom" 
        android:layout_alignBottom="@+id/headerImage" 
        android:background="@drawable/scrim_bottom" /> 
       <android.support.v7.widget.Toolbar 
        android:id="@+id/toolbar" 
        android:layout_width="match_parent" 
        android:layout_height="56dp" 
        app:titleTextColor="@color/White" 
        android:layout_gravity="right" 
        android:layoutDirection="rtl" 
        app:layout_collapseMode="pin" 
        app:popupTheme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
        app:contentInsetStartWithNavigation="0dp" 
        app:titleMarginTop="13dp"> 
        <LinearLayout 
         android:id="@+id/Location_Spinner_Layout" 
         android:orientation="horizontal" 
         android:clickable="true" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:visibility="gone" 
         android:layout_marginLeft="-15dp"> 
         <include 
          android:id="@+id/toolbar_header_view" 
          layout="@layout/toolbar_header_view" 
          android:layout_height="wrap_content" 
          android:layout_width="wrap_content" 
          android:layout_marginLeft="@dimen/header_view_end_margin_left" 
          android:visibility="invisible" /> 
         <View 
          android:layout_width="0dp" 
          android:layout_height="0dp" 
          android:layout_weight="1" /> 
         <TextView 
          android:id="@+id/dateText" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:textColor="@color/White" 
          android:background="?selectableItemBackgroundBorderless" 
          android:layout_gravity="center_vertical" 
          android:gravity="center" 
          android:textSize="13sp" /> 
        </LinearLayout> 
       </android.support.v7.widget.Toolbar> 
       <android.support.design.widget.TabLayout 
        android:id="@+id/libraryTabs" 
        android:layout_width="match_parent" 
        android:layout_height="?attr/actionBarSize" 
        android:layout_gravity="bottom" 
        app:tabIndicatorHeight="3dp" 
        android:layoutDirection="ltr" 
        android:background="?attr/colorPrimary" 
        app:tabIndicatorColor="@android:color/white" 
        android:theme="@style/ThemeOverlay.AppCompat.Dark" 
        app:tabMode="fixed" 
        app:tabGravity="fill" /> 
      </android.support.design.widget.CollapsingToolbarLayout> 
     </android.support.design.widget.AppBarLayout> 

什麼是錯我的佈局?

+0

添加工具欄上的背景顏色灰色或黑色,如果不工作添加視圖與規定的顏色和具有工具欄大小直接放置在提升的工具欄下方以提供陰影效果。 – Waqas

+0

@Waqas謝謝,但我不喜歡使用「黑客」,並解決問題 – amitairos

回答

0

試試這個我也有同樣的問題,我的作品

final AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) 
      toolbar.getLayoutParams(); 
    params.setScrollFlags(0); 
    toolbar.setLayoutParams(params);