Android Honeycomb - Changing the Actionbar style

795 views Asked by At

I need to add a right padding to the Home button of the ActionBar and I need to change its background color when it's selected. I could do these things with my tabs, which I added, implementing a new style but I couldn't change the style of my Home button. Are there any way to do it?

This is the source of the theme I have implemented:

<!-- style for the tabs -->
<style name="ActionBarTabStyle" parent="@android:style/Widget.Holo.Light.Tab">
    <item name="android:background">@drawable/button_post</item>
    <item name="android:paddingLeft">7dp</item>
    <item name="android:paddingRight">7dp</item>
    <item name="android:paddingBottom">10dp</item>
    <item name="android:paddingTop">10dp</item>
</style>

<style name="ActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:background">@color/button_post_default</item>
</style>

<style name="ActionButtonStyle" parent="@android:style/Widget.Holo.Light.ActionButton.Overflow">
    <item name="android:background">@drawable/button_post</item>
</style>

<!-- Honeycomb theme -->
<style name="Theme.Honeycomb" parent="@android:style/Theme.Holo.Light">
    <item name="android:windowNoTitle">false</item>
    <item name="android:actionBarTabStyle">@style/ActionBarTabStyle</item>
    <item name="android:actionBarStyle">@style/ActionBarStyle</item>
    <item name="android:selectableItemBackground">@drawable/button_post</item>
    <item name="android:actionOverflowButtonStyle">@style/ActionButtonStyle</item>
</style>
1

There are 1 answers

0
Wiebe Elsinga On

You can do this programmatically.

First get the View:

View homeIcon = findViewById(R.id.home); 

Now apply padding:

homeIcon.setPadding(5, 0, 0, 0);

and add Drawable by .setBackground(..) or Color by .setBackgroundColor(...)