android costumized button problem with changing text color
Posted
by
alaxid
on Stack Overflow
See other posts from Stack Overflow
or by alaxid
Published on 2011-01-14T15:26:40Z
Indexed on
2011/01/14
15:53 UTC
Read the original article
Hit count: 189
Hi,
I made a button that changes the background drawable on different states, this way:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/btn_location_pressed" /> <!-- pressed -->
<item android:state_focused="true" android:drawable="@drawable/btn_location_pressed"/> <!-- focused -->
<item android:drawable="@drawable/btn_location"/> <!-- default -->
The problem here is that I'm also trying to change the textColor as I do with the drawable but I'm not being able to. I already tried android:textColor and android:color but the first doesn't work whilst the seconds changes my background.
The next code is part of my layout. Regarding to the text color it only works for the normal state text color, thus not changing it to the white one while pressed
<Button android:id="@+id/location_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:background="@drawable/location"
android:textSize="15sp"
android:textColor="@color/location_color"
android:textColorHighlight="#FFFFFF"
/>
As anybody got a clue?
ty! :)
© Stack Overflow or respective owner