2015-09-19 109 views
0

我有一个material design navigation drawer我从this tutorial.如何使片段覆盖工具栏中的导航抽屉

它可以完美兼容toolbar和所有创建的。我可以点击抽屉中的物品,并显示相应的fragment加上标题。

但是我想使toolbar一个fragment是透明的,使得背景图像下面的图片中显示的一样: enter image description here

问题:我的问题是似乎没有启动片段这是结果:enter image description here

我不知道如何解决这个问题。任何建议都会受到欢迎。

+0

[我如何使用DrawerLayout显示在ActionBar /工具栏上和状态栏下? - 堆栈溢出] [1] [1]:http://stackoverflow.com/questions/26440879/how-do-i-use-drawerlayout-to-display-over-the-actionbar-toolbar -and-under-the-st –

+0

不,那不是我想要实现的。 –

+0

我知道如何去做你上面提出的建议。但是问题不在于drawe,而是显示了片段。 –

回答

0

使用此为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”到你想使用的背景图像的绘制。