Android deep analysis selector
The selector class is similar to the shape class, which is used to set the properties of the control in an xml file and then reference it. The basic attributes of selector are as follows:
Android: drawable = "@ drawable/pic2"/>
Android: drawable = "@ drawable/pic3"/>
You can use the following methods:
First, configure android: listSelector = "@ drawable/list_item_bg" in listview"
You can also add the property android: background = "@ drawable/list_item_bg" to the listview item.
Or use the following in java code:
Drawable drawable = getResources (). getDrawable (R. drawable. list_item_bg );
ListView. setSelector (drawable); same effect.
However, when the list is sometimes black, you need to add android: cacheColorHint = "@ android: color/transparent" to make it transparent.
Some background Effects of the Button:
Android: state_selected is selected
Android: state_focused is the focal point
Android: state_pressed: Click
Android: state_enabled is used to set whether to respond to events. It refers to all events.
You can also use selector and shape nesting:
Android: bottom = "10dp" android: right = "10dp"/>
Android: bottom = "10dp" android: right = "10dp"/>
Below is:
If you have any questions, please leave a message. If you have reprinted the message, you can indicate the source.