Changing the style attribute of a button according to its state
Posted
by LambergaR
on Stack Overflow
See other posts from Stack Overflow
or by LambergaR
Published on 2010-03-22T16:15:55Z
Indexed on
2010/03/22
16:31 UTC
Read the original article
Hit count: 305
android
I know you can change buttons background by creating a simple XML file, like this:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:state_window_focused="false"
android:state_enabled="true"
android:drawable="@drawable/button_normal"
/>
<!-- ... -->
</selection>
I was wondering if it is possible to use a similar approach to change the style
attribute of an element using the same (or similar) technique.
Or, if that is not possible, how can the style
attribute be changed during runtime (there is no such thing as button.setStyle(R.style.button)
).
© Stack Overflow or respective owner