2015-09-19 112 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」到你想使用的背景圖像的繪製。