I am trying to customize the action bar in my android application. The following is in my styles.xml:
<style name="MyTheme" parent="Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="Widget.AppCompat.Light.ActionBar">
<item name="backgroundColor">#000000</item>
</style>
And I have
<activity android:name=".MainActivity"
android:theme="#style/MyTheme">
in my AndroidManifest.xml.
My expectation is that this should turn the action bar black. However, this does not happen, the action bar stays white. I would be very happy for any pointers to why my expectation does not match reality. I am happy to provide more details if needed.
If you are using an ActionBar you can use the actionBarStyle attribute in your app theme:
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="background">#000000</item>
</style>
You can also use the actionBarTheme attribute:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarTheme">#style/ThemeOverlay.ActionBar</item>
</style>
<style name="ThemeOverlay.ActionBar" parent="">
<item name="colorPrimary">#000000</item>
</style>
Related
The following is my app theme
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
...
<item name="actionModeStyle">#style/AppStyle.ActionMode</item>
<item name="android:actionModeStyle">#style/AppStyle.ActionMode</item>
</style>
<style name="AppStyle.ActionMode" parent="Widget.AppCompat.ActionMode">
<item name="background">#color/color_action_mode_background</item>
<item name="backgroundSplit">#color/color_action_mode_background</item>
</style>
It does not work. Any suggestions ?
I'm trying to style the action bar inside my app using the code below.
<resources>
<!-- the theme applied to the application or activity -->
<style name="myTheme" parent="#style/Theme.AppCompat">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar" parent="#style/Widget.AppCompat.ActionBar">
<item name="android:textSize">24sp</item>
</style>
simply put the font should be bigger.. but nope.
Any ideas as to why?
Thanks.
Possibly your theme is not applied to activity. Set it in manifest:
<activity
android:name=".YourActivty"
android:theme="#style/myTheme" />
UPDATE 1
You should change action bar text size in such way (changing titleTextStyle):
<style name="Theme.YourTheme" parent="android:style/Theme">
<item name="android:actionBarStyle">#style/Theme.YourTheme.Styled.ActionBar</item>
</style>
<style name="Theme.YourTheme.Styled.ActionBar">
<item name="android:titleTextStyle">#style/Theme.Viadeo.Styled.YourTheme.TitleTextStyle</item>
</style>
<style name="Theme.YourTheme.Styled.ActionBar.TitleTextStyle" parent="#android:style/Widget.TextView">
<item name="android:textSize">24sp</item>
</style>
I just can't figure this one out:
I have an application with an ActionBar, I want the ActionBar to be red and the background of the app blue. I tried to achieve this with this styles.xml:
<style name="AppTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:background">#color/blue</item>
<item name="background">#color/blue</item>
<item name="android:layout_marginTop">5dp</item>
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/red</item>
<item name="background">#color/red</item>
</style>
But the actionBar is always blue. When I take away the blue background of the app, the actionBar is red as desired...
Any ideas?
The margin that you set is ambiguous and does not apply to anything. You should set the margin on your action bar theme:
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/red</item>
<item name="android:windowBackground">#color/blue</item>
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:layout_marginTop">5dp</item>
</style>
If all you're trying to do is a red action bar with a blue background, it is much easier to use the material properties included with v21+ of the support library:
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/red</item>
<item name="android:windowBackground">#color/blue</item>
</style>
i'm trying to create the a flat action bar without shadow
attached image:
my style xml
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:background">#drawable/white_bg</item>
<item name="android:displayOptions"></item>
</style>
I'm supporting android 4.x
Any ideas ? I tried changing the style to Solid/Inverse didn't work..
white_bg attached (It's hard to see since it's white)
it should look like this
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:windowContentOverlay">#null</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:windowActionBarOverlay">true</item>
<item name="android:background">#drawable/white_bg</item>
<item name="android:displayOptions"></item>
</style>
The null windowContentOverlay attribute should be set on your Activity theme (CustomActionBarTheme), not on the ActionBar theme.
I'm trying to change the "up" indicator, I've implemented the new compat action bar and I'm not able to customize it.
I've tried adding to values-v11/styles.xml
<style name="MyActionBar" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="android:icon">#drawable/ic_action_logo_barra_de_acciones_blanco</item>
<item name="android:background">#drawable/action_bar_style</item>
<item name="android:homeAsUpIndicator">#drawable/arrow_up_black</item>
</style>
and to values/styles.xml
<style name="MyActionBar" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="background">#drawable/action_bar_style</item>
<item name="icon">#drawable/ic_action_logo_barra_de_acciones_blanco</item>
<item name="homeAsUpIndicator">#drawable/arrow_up_black</item>
</style>
But is still not working.
Thanks in advance, Diego.
Sorry, maybe already late, but I had same issue and solved it by defining "homeAsUpIndicator" in main theme before ActionBar style.
Here is my res/values/styles.xml
<style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light">
</style>
<style name="AppTheme" parent="AppBaseTheme">
<item name="homeAsUpIndicator">#drawable/abc_ic_ab_back_holo_dark</item>
<item name="actionBarStyle">#style/Widget.Styled.ActionBar</item>
</style>
<style name="Widget.Styled.ActionBar" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="background">#drawable/messages_form_banner</item>
</style>
I hope it will help you.