| Author |
Message |
aetmos Junior Developer
Joined: 18 Jan 2008 Posts: 21
|
|
| Back to top |
|
 |
plusminus Site Admin

Joined: 14 Nov 2007 Posts: 2067 Location: Germany
|
|
| Back to top |
|
 |
aetmos Junior Developer
Joined: 18 Jan 2008 Posts: 21
|
Posted: Wed Feb 20, 2008 7:03 pm Post subject: |
|
|
Thanks for your help, Plusminus. After doing some digging, it looks like that the returned array holds references to "states", not drawables. For instance, when the button is focused/orange, onCreateDrawableState is returning this array: {0x101016E,0x101016F,0x1010170}. When the button isn't focused/orange, it's returning this: {0x101016F,0x1010170}. By decompiling Android's R.class, it looks like these resources are:
0x101016E: state_focused
0x101016F: state_window_focused
0x1010170: state_enabled
So, unfortunately, I still don't know where the image resources are being referenced, or how to change them...I wonder why they picked orange of all colors...
Tom |
|
| Back to top |
|
 |
aetmos Junior Developer
Joined: 18 Jan 2008 Posts: 21
|
Posted: Wed Feb 20, 2008 8:39 pm Post subject: |
|
|
SOLVED!!!!
Okay, so it's not necessary to create a custom view. The rather simple solution is posted here:
http://groups.google.com/group/android-developers/browse_thread/thread/1906f24707594f67/0714e077e25d63a6?lnk=gst&q=button#0714e077e25d63a6
| Quote: | In res/drawable, create a file called for instance mybutton_background.xml
and put something like this inside:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_pressed="false"
android:drawable="@drawable/button_background_focus" />
<item android:state_focused="true" android:state_pressed="true"
android:drawable="@drawable/button_background_pressed" />
<item android:state_focused="false" android:state_pressed="true"
android:drawable="@drawable/button_background_pressed" />
<item android:drawable="@drawable/button_background_normal" />
</selector>
Then set this drawable as the background of your button with
android:background="@drawable/mybutton_background" |
Thanks,
Tom |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
© 2007, Android Development Community
All rights reserved.
Powered by phpBB.
|