I am android beginner , I want to create status bar
as same as Toolbar
and when DrawerLayout
is opened statusBar
again change as same as DrawerLayout
,how to solve this problem . I have already set in style parent="Theme.AppCompat.Light.NoActionBar
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:background="#ed9797"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/DrawerLayout">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="#e62e2e"
android:minHeight="?attr/actionBarSize"
app:contentInsetEnd="0dp"
app:contentInsetStart="0dp">
</android.support.v7.widget.Toolbar>
</RelativeLayout>
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ListView
android:background="#46dfcd"
android:id="@+id/leftDrawer"
android:layout_width="250dp"
android:layout_height="match_parent"
android:text="Drawer page"
android:layout_gravity="start"/>
To change status bar color use setStatusBarColor(int color).
Working snippet of code:
Window window = activity.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.setStatusBarColor(activity.getResources().getColor(R.color.example_color));