如何使片段覆盖工具栏中的导航抽屉
问题描述:
我有一个material design navigation drawer
我从this tutorial.如何使片段覆盖工具栏中的导航抽屉
它可以完美兼容toolbar
和所有创建的。我可以点击抽屉中的物品,并显示相应的fragment
加上标题。
但是我想使toolbar
一个fragment
是透明的,使得背景图像下面的图片中显示的一样:
我不知道如何解决这个问题。任何建议都会受到欢迎。
答
使用此为toolbar.xml:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/toolbar_image"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
local:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</FrameLayout>
当然,你需要改变“@绘制/ toolbar_image”到你想使用的背景图像的绘制。
[我如何使用DrawerLayout显示在ActionBar /工具栏上和状态栏下? - 堆栈溢出] [1] [1]:http://*.com/questions/26440879/how-do-i-use-drawerlayout-to-display-over-the-actionbar-toolbar -and-under-the-st –
不,那不是我想要实现的。 –
我知道如何去做你上面提出的建议。但是问题不在于drawe,而是显示了片段。 –