0

i am using material design navigation drawer in which i want to make my drawerlayout under transparent status bar in android kitkat 4.4 version for that i have used fitsystemwindow true but when using fitsystem window true it shows white statusbar also i have used android:windowTranslucentStatus true and android:windowTranslucentNavigation false in my style.xml under values-v19 but still it showing me white status bar in android kitkat 4.4 it's easy to achive in lolipop that i know for statusbar so how to make statusbar transparent in android kitkat 4.4 i have googling lots of for that but non of solution is worked for me.please help me to resolve this issue.Thanks in Advance.

values-v19/style.xml

 <resources xmlns:android="http://schemas.android.com/tools">

        <!-- Base application theme. -->
        <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
            <!-- Customize your theme here. -->
            <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
            <item name="colorPrimary">@color/colorPrimary</item>
            <item name="android:windowTranslucentStatus">true</item>
            <item name="android:windowTranslucentNavigation">false</item>


        </style>

    </resources>

activity_main.xml

 <?xml version="1.0" encoding="utf-8"?>

<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"
    android:fitsSystemWindows="true">

    <android.support.design.widget.CoordinatorLayout
        android:id="@+id/coordinator"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:paddingTop="5dp"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                android:theme="@style/ThemeOverlay.AppCompat.Dark" />

            <android.support.design.widget.TabLayout
                android:id="@+id/tablayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="?attr/colorPrimary"
                android:theme="@style/ThemeOverlay.AppCompat.Dark"
                app:tabGravity="fill"
                app:tabIndicatorColor="#f8f880"
                app:tabSelectedTextColor="#ff8800"
                app:tabTextColor="#ffffff" />

            <android.support.v4.view.ViewPager
                android:id="@+id/viewpager"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

        </LinearLayout>

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_gravity="bottom|right"
            android:layout_marginBottom="@dimen/activity_vertical_margin"
            android:layout_marginRight="@dimen/activity_horizontal_margin"
            android:src="@drawable/ic_done" />

    </android.support.design.widget.CoordinatorLayout>


    <android.support.design.widget.NavigationView
        android:id="@+id/navigation_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="#ffffff"
        app:headerLayout="@layout/drawer_header"
        app:menu="@menu/drawer" />
</android.support.v4.widget.DrawerLayout>
Viral
  • 128
  • 1
  • 15

1 Answers1

1

For API 21+

<style name="AppTheme" parent="android:Theme.Holo.NoActionBar.TranslucentDecor">
    ...
</style>

For API level 19+

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="android:windowTranslucentStatus">true</item>
</style>

Also your layout should have android:fitsSystemWindows="false"

NOTE: In Android KitKat you cannot change the color of the status bar except if you use the following solution because only in Lollipop Google introduced the attribute statuBarColor

So for that you need to check this transparent status bar in KITKAT

prat
  • 795
  • 5
  • 14
  • I am using appcompact theme as defined above questions theme.appcompact.light.noactionbar also used fitsystemwindow false so it make only half portion ie when drawer open its width size of status bar shows me white colour nothing works as you told – Viral Jun 04 '16 at 09:13
  • can u post the screenshot of ur issue – prat Jun 04 '16 at 09:14
  • Wait I will send you some time later – Viral Jun 04 '16 at 09:16
  • I want to make status bar color transparent and put drawer behind that in Android kitkat version is it possible. Its possible in lollipop 5.0 but what about kitkat 4.4 version – Viral Jun 04 '16 at 09:26
  • It's not possible to have transparent status bar for kitkat version but u can code for it as illustrated in my updated answer, – prat Jun 04 '16 at 10:06
  • Thanks for sharing your knowledge and help me – Viral Jun 04 '16 at 11:41
  • When I make fitsystemwindow true statusbar shows me white colour why this happens – Viral Jun 04 '16 at 11:43
  • U could check this for more info http://stackoverflow.com/questions/26745300/navigation-drawer-semi-transparent-over-status-bar-not-working – prat Jun 04 '16 at 11:47
  • i have checked that not only this tag in values-v19 style.xml true that make stausbar tarnslucent in android kitkat but also need following code programaticallly its required otherwise when drawer open its width size of status bar shows me white color – Viral Jun 05 '16 at 07:23
  • 1
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { Window w = getWindow(); // in Activity's onCreate() for instance w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); } – Viral Jun 05 '16 at 07:25