1
我試圖在抽出時將導航抽屜上的陰影投射到工具欄上,同時還允許將陰影投射到其餘的佈局。如何在使用CoordinatorLayout時刪除導航抽屜在工具欄上投下的陰影
我知道我可以通過在父視圖中包裝DrawerLayout並在該父視圖中添加工具欄來刪除陰影,但通過這樣做,我無法使滾動佈局時工具欄滾動屏幕,因此這不是對我來說可行的解決方案。
我可能會使用AppBarLayout的偏移偵聽器以編程方式將工具欄從屏幕上退出,但純粹的XML解決方案可能是最好的。
我使用這個佈局:
<android.support.v4.widget.DrawerLayout
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/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity"
>
<android.support.design.widget.CoordinatorLayout 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:clipChildren="true"
>
<android.support.design.widget.AppBarLayout
app:layout_scrollFlags="scroll"
android:id="@+id/profile_screen_appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true"
android:minHeight="150dp"
>
<android.support.design.widget.CollapsingToolbarLayout
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7"
app:layout_scrollFlags="scroll"
android:fitsSystemWindows="true"
android:id="@+id/collapsingToolbarCurrentUser"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<android.support.v7.widget.Toolbar
android:minHeight="0dp"
android:fitsSystemWindows="false"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/recycler"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
</android.support.design.widget.CoordinatorLayout>
<fragment
android:fitsSystemWindows="true"
android:id="@+id/fragment_drawerInTesterActivity"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
app:layout="@layout/fragment_nav_bar"
android:name="Fragment"
tools:layout="@layout/fragment_nav_bar"/>
</android.support.v4.widget.DrawerLayout>
問題一言以蔽之:如何刪除由抽屜式導航欄上的工具欄的陰影,同時允許工具欄是一個CoordinatorLayout內滾動視圖?