I have a problem implementing the translucent status and navigation bar in Android 4.4...
So, when I enable the translucent status und nav bar, even after declaring FitsSystemWindows and ClipToPadding, even the ActionBar goes behind the Status bar.
Here's my theme, maybe there is an error there:
<style name="Theme.Start" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/ActionBar.Transparent.Start</item>
<item name="android:colorBackground">#android:color/white</item>
<item name="android:windowBackground">#android:color/white</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:fitsSystemWindows">true</item>
<item name="android:clipToPadding">false</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
This can occur when your actionbar contain only a title.
The following work for me
<style name="AppTheme" parent="android:Theme.Holo.Light">
<item name="android:windowActionBarOverlay">true</item>
<item name="android:fitsSystemWindows">false</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
Be sure to init your actionbar Home button after your setContentView()
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);
Does it solve your problem?
Related
I want to make my status bar and navigation bar transparent (not translucent).
<style name="FullScreenDialog" parent="#android:style/Theme.Dialog">
<item name="android:windowBackground">#null</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowFrame">#null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:statusBarColor">#android:color/transparent</item>
<item name="android:navigationBarColor">#android:color/transparent</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowLightStatusBar">false</item>
<item name="android:background">#null</item>
</style>
I have tried a number of different combinations but none seem to work. This current setup gives me a black status bar background. I'm sure I'm missing something simple. I have also tried using:
android:fitsSystemWindows="true"
On my layouts.
Thank you for the help.
how can I change the back ground color of split action bar in android?In my application both split actionbar and actionbar is there.
You can change action bar style through style.xml from values.
working with Android API 11+
<style name="Theme.Suthar" parent="#style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/ActionBar.Solid.Suthar</item>
</style>
<style name="ActionBar.Solid.Suthar" parent="#style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/red</item>
<item name="android:backgroundStacked">#color/yellow</item>
<item name="android:backgroundSplit">#color/green</item>
</style>
For AppCompat Theme:
<style name="Theme.Suthar" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarStyle">#style/ActionBar.Solid.Suthar</item>
</style>
<style name="ActionBar.Solid.Suthar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="background">#color/red</item>
<item name="backgroundStacked">#color/yellow</item>
<item name="backgroundSplit">#color/green</item>
</style>
I had a problem with toolbar and status bar. I change the app styles to AppCompat. My styles are:
for values/styles.xml
<style name="AppTheme" parent="Theme.AppCompat">
<item name="colorPrimary">#color/color_primario_500</item>
<item name="colorPrimaryDark">#color/color_primario_500</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
for values-v21/styles.xml:
<style name="AppTheme" parent="AppTheme.BaseGps">
<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowSharedElementEnterTransition">#android:transition/move</item>
<item name="android:windowSharedElementExitTransition">#android:transition/move</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
My problem is that half the toolbar appears behind status bar. In the next image you can see what happens.
Any ideas? Thanks in advance!!
The solution is apply the item
<item name="android:windowTranslucentStatus">false</item>
in the styles.
I don't like these answers. Just because with Material design a Navigation Drawer should overlap the toolbar and have a translucent status bar so long as the API level supports it.
If you want the toolbar to fit properly and have a translucent status bar then you just need these items in your style.
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowTranslucentStatus">true</item>
I am trying to change the background color of actionbar in my App but this is showing different on my app. Instead of coloring the actionbar the whole activity is color.
I am not sure why this is happening? I just want the main actionbar and settings actionbar colored.
Please check the screenshot.
Main Activity Map:
Preference Settings:
I also have transparent Actionbar with UP Navigation enabled for all my sub activities other than the main activity and preference settings activity.
I am not sure why it is showing like the above:
Here is style.xml (values-v14):
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:background">#FF5050</item>
</style>
<style name="dialogtheme" parent="#android:style/Theme.Holo.Light.DarkActionBar"></style>
<!-- Transparent ActionBar Style -->
<style name="AppTheme.Light.ActionBar.Transparent" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#android:color/transparent</item>
</style>
<!-- Activity Theme with transparent ActionBar -->
<style name="AppTheme.TransparentActionBar.Light" parent="#style/AppBaseTheme">
<item name="android:actionBarStyle">#style/AppTheme.Light.ActionBar.Transparent</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:displayOptions">showHome|homeAsUp|showTitle</item>
<item name="android:icon">#android:color/transparent</item>
<item name="android:actionBarTabTextStyle">#style/ActionBarTabTextStyle.Tabtheme</item>
<item name="android:actionBarDivider">#drawable/verticallinefordivder</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabStyle.MapsLocation</item>
</style>
<style name="simpledialog" parent="android:Theme.Holo.Light.Dialog">
<item name="android:windowNoTitle">true</item>
</style>
<style name="ActionBarTabTextStyle.Tabtheme" parent="#style/AppBaseTheme">
<item name="android:textSize">18sp</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">#android:color/black</item>
</style>
<style name="ActionBarTabStyle.MapsLocations" parent="#android:style/Widget.Holo.Light.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator</item>
</style>
<style name="myPreferenceTheme" parent="#style/AppBaseTheme">
<item name="android:textColor">#color/blue</item>
</style>
<style name="Widget.ActionButton" parent="#style/AppBaseTheme">
<item name="android:background">?android:attr/actionBarItemBackground</item>
<item name="android:paddingLeft">12dip</item>
<item name="android:paddingRight">12dip</item>
<item name="android:minWidth">56dip</item>
<item name="android:minHeight">?android:attr/actionBarSize</item>
</style>
</resources>
A little change and you action bar will be red:
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/AppTheme.Light.ActionBar</item>
</style>
<style name="dialogtheme" parent="#android:style/Theme.Holo.Light.DarkActionBar"></style>
<!-- Transparent ActionBar Style -->
<style name="AppTheme.Light.ActionBar" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:background">#FF5050</item>
</style>
I have changed item in AppBaseTheme & AppTheme.Light.ActionBar .
Now you are good to go. let me know if it works however working at my end :P
You can try set custom view in action bar.
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setCustomView(you_custom_layout);
I know this is not right answer to this question but if you want to edit your ActionBar, you can use this online Android Action Bar Style Generator.
At least you can create a style and check yours to find differences and learn how to edit your ActionBar.
I've set a custom background for my application, and it seems that doing so has caused the ordinarily black background of my ActionBar to become transparent. This makes it difficult to work with the search field I plan on adding to it.
I've tried overriding this with the following:
<style name="app_theme" parent="Theme.AppCompat">
<item name="android:windowBackground">#drawable/app_background</item>
<item name="android:listViewStyle">#style/TransparentListView</item>
<item name="android:expandableListViewStyle">#style/TransparentExpandableListView</item>
<item name="android:actionBarStyle">#style/MyTheme.ActionBarStyle</item>
</style>
<style name="Mytheme.ActionBarStyle" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:windowActionBarOverlay">true</item>
</style>
This does not seem to correct my issue. How can I ensure that my action bar is black like it should be?
You can set action bar color like below:
ActionBar bar = getActionBar();
bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#3BB9FF")));
if you want transparent action bar then check this link:
http://cyrilmottier.com/2013/05/24/pushing-the-actionbar-to-the-next-level/
Also you can try xml style:
<style name="AppTheme" parent="android:Theme.Holo">
<item name="android:windowActionBarOverlay">true</item>
<item name="android:actionBarStyle">#style/action_bar_theme</item>
<item name="android:actionMenuTextColor">#fff</item>
</style>
<style name="action_bar_theme" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:background">#b3000000</item>
<item name="android:titleTextStyle">#style/action_bar_text</item>
</style>
Hope this will help....