Reputation: 3074
I am having problem with status bar color when I use android:fitsSystemWindows="false"
It becomes transparent. I dont want that to happen. I want to it have colorPrimaryDark
as its color.
I have to set this as false
because I am using a FrameLayout
in main layout so that I can inflate a overlay fragment, When android:fitsSystemWindows="false"
is set true
the overlay occupies whole screen, I dont want that to happen with overlay fragment.
my activity_main looks like this.
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:background="@drawable/layout_bg_white"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false"
tools:openDrawer="start"
tools:context="com.example.tabstrial2.MainActivity">
<RelativeLayout
android:id="@+id/main_layout_of_app"
android:layout_width="match_parent"
android:layout_height="match_parent">
</RelativeLayout>
<FrameLayout
android:id="@+id/overlay_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="56dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="119dp" />
</android.support.v4.widget.DrawerLayout>
style.xml looks like this.
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#500347</item>
<item name="colorPrimaryDark">#862b7b</item>
<item name="colorAccent">#1a2fcf</item>
<item name="android:textColor">#ffffff</item>
<item name="colorControlHighlight">#fff</item>
<item name="colorControlActivated">@android:color/holo_green_dark</item>
<item name="colorControlNormal">#fff</item> <!-- normal border color change as you wish -->
<item name="colorButtonNormal">#500347</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="AppTheme.Picker" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:textColorPrimary">@android:color/white</item>
</style>
<!--<style name="AppTheme.CheckBox" parent="Theme.AppCompat.Light.NoActionBar">-->
<!--<item name="android:colorAccent">@android:color/white</item>-->
<!--</style>-->
<style name="MyCheckBox" parent="Theme.AppCompat.NoActionBar">
<item name="colorControlNormal">#fff
</item> <!-- normal border color change as you wish -->
<item name="colorControlActivated">#fff</item> <!-- activated color change as you wish -->
<item name="android:textColor">#FFFF3F3C</item> <!-- checkbox text color -->
</style>
Upvotes: 0
Views: 163
Reputation: 71
In your Activity below the setcontentview(...)
Window window = getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
// finally change the color
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.setStatusBarColor(Color.parseColor("#c2212a"));
}
Upvotes: 2
Reputation: 3112
You can try to set the status bar color explicit
<item name="android:statusBarColor">@color/color_primary_dark</item>
or set the translucent status to false
<item name="android:windowTranslucentStatus">false</item>
Upvotes: 0