2017-02-04 136 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

解决我的问题 –