1

I just want bring my navigation drawer under status bar every thing works fine but problem is my status bar is shadow .

enter image description here

How can i change it to transparent , like play store app .

Here is my app theme

<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>

and main activity 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>
mR.Rian
  • 615
  • 2
  • 6
  • 28

2 Answers2

0

You can simply change Android status bar color as transparent. this will help you.

     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));
Lovekush Vishwakarma
  • 3,035
  • 23
  • 25
0

ok i fix it my self if you have similar problem remove all these lines from your theme

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

and just add

android:fitsSystemWindows="true"

to your main liniear layout

mR.Rian
  • 615
  • 2
  • 6
  • 28
  • 1
    That's not a fix you are just setting the color same as the below view's color to make total view visible as same color thing! This will work as long as you dont set any background image – Charuක Feb 04 '17 at 17:17
  • that fix my problem – mR.Rian Feb 04 '17 at 17:25