Veer3383
Veer3383

Reputation: 1825

How to get systembar tint without overlapping navigation bar in android?

This is what i want. I get this when i disable the statusbar tint, but here status bar gets White background which looks bad and not my requirement.

This is when i enable the statusbar tint, i get the the color specified, but it also overlaps the drawer which i dont want.

This is my current XML, with which i am getting the above output. How can i get the tint effect without overlapping the drawer?

<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/drawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="false"
    >        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:fitsSystemWindows="true"
            android:weightSum="1">

            <include
                android:id="@+id/toolbar"
                layout="@layout/toolbar"
               />
        </LinearLayout>
        <com.heinrichreimersoftware.materialdrawer.DrawerView
            android:id="@+id/drawer"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="start"/>
    </android.support.v4.widget.DrawerLayout>

I am using Systembar tint library by ready state softwares to get get transculent status bar on kitkat.

Upvotes: 0

Views: 306

Answers (2)

user5566381
user5566381

Reputation:

Add this to your theme, this will make your toolbar transparent

<item name="android:windowBackground">@android:color/transparent</item>

Add this in your colors xml for transparent color

<color name="transparent">#00000000</color>

Upvotes: 1

Arnaldo
Arnaldo

Reputation: 683

Maybe this can help You:

Place all within a RelativeLayout with android:fitsSystemWindows="true":

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.v4.widget.DrawerLayout
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/drawerLayout"
        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:weightSum="1">

            <include
                android:id="@+id/toolbar"
                layout="@layout/toolbar" />

        </LinearLayout>

        <com.heinrichreimersoftware.materialdrawer.DrawerView
            android:id="@+id/drawer"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="start"/>

    </android.support.v4.widget.DrawerLayout>

</RelativeLayout>

EDIT/CREATE STYLES RESOURCES

/values/styles.xml:

    <resources>

    <style name="AppTheme" parent="AppTheme.Base"/>

    <style name="AppTheme.Base" parent="Theme.AppCompat.NoActionBar">
        <item name="colorPrimaryDark">@color/primary_dark</item>
        <item name="colorPrimary">@color/primary</item>
        <item name="colorAccent">@color/accent</item>
        <item name="android:windowBackground">@color/primary_dark</item>
    </style>

</resources>

/values-v19/styles.xml: (for Kitkat)

<resources>

    <style name="AppTheme" parent="AppTheme.Base">
        <item name="android:windowTranslucentStatus">true</item>
    </style>

</resources>

/values-v21/styles.xml: (for Lollipop)

<resources>

    <style name="AppTheme" parent="AppTheme.Base"/>
        <item name="android:colorPrimaryDark">@color/primary_dark</item>
        <item name="android:colorPrimary">@color/primary</item>
        <item name="android:colorAccent">@color/accent</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:statusBarColor">@android:color/transparent</item>
    </style>

</resources>

Upvotes: 0

Related Questions