我的主要布局有CoordinatorLayout
,其中包含AppBarLayout
,CollapsingToolbarLayout
,Toolbar
和TabLayout
。
但是,工具栏不显示阴影。
这是我的布局:
<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 :(得分:0)
尝试这个我也有同样的问题,它对我有用
final AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams)
toolbar.getLayoutParams();
params.setScrollFlags(0);
toolbar.setLayoutParams(params);