How to customize Action Bar Style? - android

How to change the color of Action Bar Back Button and Action bar Menu Icon(Image attached).
I have the following style code(below), using which I customized the Text but I'm not able to completely customize the Action Bar.
Below is the Style code which I have used :
<style name="MyCustomTheme" parent="Theme.Sherlock.Light">
<item name="actionBarStyle">#style/ActionBar</item>
<item name="android:actionBarStyle">#style/ActionBar</item>
</style>
<style name="ActionBar" parent="Widget.Sherlock.ActionBar">
<item name="background">#drawable/bg_header</item> -----------(1)
<item name="android:background">#drawable/bg_header</item>
<item name="android:titleTextStyle">#style/customTextAppearance.Sherlock.Widget.ActionBar.Title</item> ----(2)
<item name="titleTextStyle">#style/customTextAppearance.Sherlock.Widget.ActionBar.Title</item>
<item name="android:homeAsUpIndicator">#style/customTextAppearance.Sherlock.Widget.ActionBar.Title</item>
</style>
<style name="customTextAppearance.Sherlock.Widget.ActionBar.Title" parent="TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textSize">18dp</item>
<item name="android:textColor">#ffffff</item>
<item name="android:shadowColor">#ffffff</item>
<item name="android:shadowDy">3</item>
<item name="android:textStyle">bold</item>
</style>
Your help will be appreciated, Thank you.

Just find proper icons for your actionbar and customize it...
and then make changes in your...
You Can Do Following For Changing Icons Of Actionbar
style.xml
<style name="Widget.ActionButton.Overflow" parent="#android:style/Widget.Holo.ActionButton.Overflow">
<item name="android:src">#drawable/ic_action_overflow</item>
</style>
<style name="Your.Theme" parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionOverflowButtonStyle">#style/Widget.ActionButton.Overflow</item>
<item name="android:homeAsUpIndicator">#drawable/my_fancy_up_indicator</item>
</style>

check out this page on android help https://developer.android.com/training/basics/actionbar/styling.html
When supporting Android 3.0 and higher only,
you can define the action bar's background like this: res/values/themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="#android:style/Theme.Holo.Light.DarkActionBar">
<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:background">#drawable/actionbar_background</item>
</style>
</resources>
Then apply your theme to your entire app or individual activities:
<application android:theme="#style/CustomActionBarTheme" ... />
For Android 2.1 and higher
When using the Support Library, the same theme as above must instead look like this:
res/values/themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#drawable/actionbar_background</item>
<!-- Support library compatibility -->
<item name="background">#drawable/actionbar_background</item>
</style>
</resources>
Then apply your theme to your entire app or individual activities:
<application android:theme="#style/CustomActionBarTheme" ... />

Related

How to change ActionBar Colour

I am trying to change my App ActionBar colour to no success. I am using the this library https://github.com/neokree/MaterialNavigationDrawer;
Here is the style.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:actionBarStyle">#style/AppTheme.ActionBar</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">#style/AppTheme.ActionBar</item>
<item name="colorControlActivated">#color/color_c</item>
<item name="toolbarStyle">#style/Widget.Toolbar</item>
</style>
<style name="Widget.Toolbar" parent="#style/Widget.AppCompat.Toolbar">
<item name="contentInsetStart">5dp</item>
</style>
<style name="AppTheme.ActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/color_a</item>
<item name="background">#color/color_a</item>
<!-- Support library compatibility -->
</style>
<style name="FullscreenTheme" parent="android:Theme.NoTitleBar">
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowBackground">#null</item>
</style>
<style name="MyNavigationDrawerTheme" parent="MaterialNavigationDrawerTheme.Light.DarkActionBar">
<item name="colorPrimary">#color/color_a</item>
<item name="colorPrimaryDark">#color/color_a</item>
<item name="colorAccent">#FFFFFF</item>
<item name="rippleBackport">true</item>
<item name="singleAccount">true</item>
<item name="multipaneSupport">true</item>
<!--<item name="learningPattern">false</item>-->
</style>
<style name="MySubheaderTheme">
<item name="subheaderTitleColor">#000000</item>
</style>
<style name="MySectionTheme" >
<item name="sectionColorIcon">#000000</item>
<item name="sectionColorText">#000000</item>
<item name="sectionColorNotification">#000000</item>
<item name="sectionBackgroundColorPressed">#160000FF</item>
<item name="sectionBackgroundColorSelected">#0A0000FF</item>
<item name="sectionBackgroundColor">#000000FF</item>
</style>
</resources>
I use the MyNavigationDrawerTheme theme for my activities.
You should be able to set the action bar color using the android:colorPrimary attribute:
<resources>
<!-- inherit from the material theme -->
<style name="AppTheme" parent="android:Theme.Material">
<!-- Main theme colors -->
<!-- your app branding color for the app bar -->
<item name="android:colorPrimary">#color/primary</item>
<!-- darker variant for the status bar and contextual app bars -->
<item name="android:colorPrimaryDark">#color/primary_dark</item>
<!-- theme UI controls like checkboxes and text fields -->
<item name="android:colorAccent">#color/accent</item>
</style>
</resources>
Based on information here
You should create your styles also for v21 and above with a small change (because they natively support material theme).
And in values-v21/style.xml add android:colorPrimary and others attributes with android: prefix to your style:
<style name="MyNavigationDrawerTheme" parent="MaterialNavigationDrawerTheme.Light.DarkActionBar">
<item name="android:colorPrimary">#color/color_a</item>
<item name="android:colorPrimaryDark">#color/color_a</item>
<item name="android:colorAccent">#FFFFFF</item>
<!--...-->
</style>

Styling the android action bar?

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>

Changing the colour of ActionBar in Android

Here is my xml code in styles.xml to change theme and colour of ActionBar.
<?xml version="1.0" encoding="utf-8"?>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:icon">#drawable/brand_logo</item>
<item name="android:background">#ff5d44</item>
</style>
Here is the documentation. My app supports API level 11 and higher. Not sure where I am going wrong. Please help.
set "AppTheme" as theme for application / activity.
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">#android:color/white</item>
</style>
For more check THIS ,THIS and THIS
I was using support library. So here is the fix.
<style name="MyActionBar"
parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#ff5d44</item>
<item name="android:titleTextStyle">#style/MyActionBarTitleText</item>
<!--Support library compatibility-->
<item name="background">#color/orange</item>
<item name="titleTextStyle">#style/MyActionBarTitleText</item>
</style>

Android Flat ActionBar (without shadow)

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.

android add background to action bar

I am using support library to add an action bar.
in res/values/styles:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme" parent="android:Theme"></style>
<style name="Theme.Transparent">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">#android:style/Animation.Translucent</item>
<item name="android:windowBackground">#drawable/transparent_background</item>
<item name="android:windowNoTitle">true</item>
<item name="android:colorForeground">#fff</item>
</style>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="#style/Theme.AppCompat">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:actionBarTabTextStyle">#style/MyActionBarTabText</item>
<item name="android:actionMenuTextColor">#color/actionbar_text</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">#style/MyActionBar</item>
<item name="actionBarTabTextStyle">#style/MyActionBarTabText</item>
<item name="actionMenuTextColor">#color/actionbar_text</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="#style/Widget.AppCompat.ActionBar">
<item name="android:titleTextStyle">#style/MyActionBarTitleText</item>
<!-- Support library compatibility -->
<item name="titleTextStyle">#style/MyActionBarTitleText</item>
</style>
<!-- ActionBar title text -->
<style name="MyActionBarTitleText"
parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/actionbar_text</item>
<!-- The textColor property is backward compatible with the Support Library -->
</style>
<!-- ActionBar tabs text -->
<style name="MyActionBarTabText"
parent="#style/Widget.AppCompat.ActionBar.TabText">
<item name="android:textColor">#color/actionbar_text</item>
<!-- The textColor property is backward compatible with the Support Library -->
</style>
</resources>
and then when i add this
application android:theme="#style/CustomActionBarTheme"
to mainfest, the application falls to start. if i removed it the application works perfectly
help pelase
Try using: Action bar stylle generator. It's simple and works perfectly for default, ActionBarSherlock, Holoeverywhere themes.

Categories

Resources