2017-02-04 78 views
0

我只想把我的導航抽屜放在狀態欄下,每件事情都能正常工作,但問題是我的狀態欄是影子。Android狀態欄是影子

enter image description here

我怎樣才能將其更改爲透明的,像Play商店應用。

這裏是我的應用程序的主題

<item name="colorPrimary">@color/colorPrimaryDark</item> 
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
<item name="colorAccent">@android:color/white</item> 
<item name="android:windowTranslucentStatus">true</item> 
<item name="android:windowTranslucentNavigation">true</item> 
<item name="windowActionBarOverlay">true</item> 
<item name="android:windowDrawsSystemBarBackgrounds">true</item> 

<item name="android:statusBarColor">?attr/colorControlHighlight</item> 

和主要活動的XML

<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <!-- This LinearLayout represents the contents of the screen --> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

     <!-- The ActionBar displayed at the top --> 
     <include 
      layout="@layout/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 

     <android.support.design.widget.TabLayout 
      android:id="@+id/tab_layout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/toolbar" 
      android:background="?attr/colorPrimary" 
      android:elevation="0dp" 
      android:minHeight="?attr/actionBarSize" 
      android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/> 

     <android.support.v4.view.ViewPager 
      android:id="@+id/pager" 
      android:layout_width="match_parent" 
      android:layout_height="fill_parent" 
      android:layout_below="@id/tab_layout"/> 


     <!-- The main content view where fragments are loaded --> 
     <FrameLayout 
      android:id="@+id/flContent" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 
    </LinearLayout> 


    <android.support.design.widget.NavigationView 
     android:id="@+id/nvView" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     app:headerLayout="@layout/nav_header" 
     android:fitsSystemWindows="false" 
     android:layout_gravity="start" 
     app:menu="@menu/drawer_view" /> 
</android.support.v4.widget.DrawerLayout> 
+0

你可以按照這個簡單的教程:https://github.com/codepath/android_guides/wiki/Fragment-Navigation-Drawer –

+0

我的問題是狀態欄顏色不是如何建立導航抽屜 –

+0

你可以發佈你的佈局的代碼? –

回答

0

您可以簡單地改變Android狀態欄的顏色爲透明。 這會幫助你。

 Window window = activity.getWindow(); 
    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); 
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); 

    /*----set color----*/ 
    window.setStatusBarColor(activity.getResources().getColor(R.color.my_statusbar_color)); 
0

好吧,我解決它我自己,如果你有類似的問題,從你的主題

<item name="android:windowTranslucentStatus">true</item> 
<item name="android:windowTranslucentNavigation">true</item> 
<item name="windowActionBarOverlay">true</item> 
<item name="android:windowDrawsSystemBarBackgrounds">true</item> 

,並刪除所有這些行只加

android:fitsSystemWindows="true" 

到主liniear佈局

+0

這不是一個修復,你只是設置顏色相同在視圖的顏色下方,使全視圖看起來像是一樣的顏色!這將工作,只要你不設置任何背景圖片 –

+0

解決我的問題 –