[英]How to remove the shadow cast by the navigation drawer over the Toolbar when using a CoordinatorLayout
I am trying to remove the shadow cast over the Toolbar by the navigation drawer when it is pulled out whilst also allowing the shadow to be cast over the rest of the layout. 我试图在拉出工具栏时移除工具栏上投下的阴影,同时也允许阴影投射到布局的其余部分。
I understand I can remove the shadow by wrapping the DrawerLayout in a parent view and adding the Toolbar in that parent view but by doing this I am unable to make the Toolbar scroll off screen when the layout is scrolled so this is not a viable solution for me. 我理解我可以通过将DrawerLayout包装在父视图中并在该父视图中添加工具栏来删除阴影但是通过这样做我无法在滚动布局时使工具栏滚动屏幕,因此这不是一个可行的解决方案我。
I may be able to programatically scroll the Toolbar off the screen using the offset listener of the AppBarLayout but a purely XML solution may be best. 我可以使用AppBarLayout的偏移侦听器以编程方式在屏幕上滚动工具栏,但纯粹的XML解决方案可能是最好的。
I am using this layout: 我正在使用这种布局:
<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>
Problem in a nutshell: How do I remove the shadow cast by the navigation drawer over the Toolbar whilst allowing the Toolbar to be a scrollable view inside a CoordinatorLayout ? 问题简而言之:如何在工具栏上删除导航抽屉投射的阴影,同时允许工具栏成为CoordinatorLayout内的可滚动视图?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.