Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change HomeButton Hilight Color when press

i use Sherlock Actionbar

1, i wanna change Home Button BG when i press from blue to Red

2, i wanna change HomeAsUp icon (white arrow) any idea ?

enter image description here Home button

enter image description here pressed

here is created this actionbar code

extends SherlockFragmentActivity

public ActionBar actionBar;

this.actionBar = this.getSupportActionBar();
this.actionBar.setDisplayShowHomeEnabled(true);
this.actionBar.setHomeButtonEnabled(true);
this.actionBar.setDisplayHomeAsUpEnabled(true);
like image 519
Intathep Avatar asked Jun 26 '12 06:06

Intathep


People also ask

How can I change button color when pressed?

To change a button's color every time it's clicked:Add a click event listener to the button. Each time the button is clicked, set its style. backgroundColor property to a new value. Use an index variable to track the current and next colors.

How can I change button text color on button clicked or pressed?

..... <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="bonjour !" android:textColor="@color/button_text_color" /> ..... Not @drawable/button_text_color , but @color/button_text_color .

How can I change the color of text inside a button?

Use a semi-colon to separate the different style elements in the HTML button tag. Type color: in the quotation marks after "style=". This element is used to change the text color in the button. You can place style elements in any order in the quotation markers after "style=".


2 Answers

You can change this by specifying your own actionBarItemBackground attribute in your theme.

For example,

<style name="Theme.MyTheme" parent="Theme.Sherlock">
    <item name="android:actionBarItemBackground">@drawable/my_cool_drawable</item>
    <item name="actionBarItemBackground">@drawable/my_cool_drawable</item>
</style>

and then specify Theme.MyTheme in the manifest for your activity.

like image 126
Jake Wharton Avatar answered Oct 19 '22 19:10

Jake Wharton


usually when you want to create this behavior in Android, you need to create a new selector file (xml in /drawable folder).

in that file what you want to do is choose the different states for the button and choose the different images for them.

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/pressed_image" android:state_pressed="true"></item>
    <item android:drawable="@drawable/regular_image"></item>

</selector>

edit:

you need to do this in the actionbarSherlock library of course.

like image 26
thepoosh Avatar answered Oct 19 '22 21:10

thepoosh