I made a little demonstrative app as a complete example of how StateListManager is used control combinations of states, and how to change either normal background images or 9patch background images based on the state.
You can see the difference between using the same resized image as 9patch drawable or bitmap drawable.
You have 3 switches to control the buttons states.
The app shows the current button state both with different images and with text in the middle label.
The app enables at the start the property "FocusableInTouchMode" for both example buttons, so they can be focused (because it's disabled by default on touchscreen devices).
That enables us to notice, for example, that if you press an unfocused button, it gets pressed and then AFTER you release it, it gains the focus.
You can play try new combinations and. And if you improve it, please share it in this thread. Have fun!
------
UPDATE 2012-02-23: Added SetTextColorList method, to change the TextColor property depending on the state.
You can see the difference between using the same resized image as 9patch drawable or bitmap drawable.
You have 3 switches to control the buttons states.
The app shows the current button state both with different images and with text in the middle label.
The app enables at the start the property "FocusableInTouchMode" for both example buttons, so they can be focused (because it's disabled by default on touchscreen devices).
That enables us to notice, for example, that if you press an unfocused button, it gets pressed and then AFTER you release it, it gains the focus.
You can play try new combinations and. And if you improve it, please share it in this thread. Have fun!
------
UPDATE 2012-02-23: Added SetTextColorList method, to change the TextColor property depending on the state.
Attachments
Last edited: