Android custom button control to realize button click color change

The renderings are as follows:

1、 Shape style: (in drawable new -- drawable resource file, add item in parent label selector)

2、 Style:

3、 The button control calls the style:

----------------------------------Button click color change-----------------------------------------------------

----------------------------------Item attribute tag------------------------------

android:state_ Pressed whether to press, such as a button touch or click.

android:state_ Whether focused gets the focus, for example, the user selects a text box.

android:state_ Whether the hovered cursor hovers is usually the same as the focused state, which is a new feature of 4.0

android:state_ Selected is selected, which is not exactly the same as focus state. For example, when a list view is selected, its subcomponents may be selected through the direction key.

android:state_ Whether the checkable component can be checked. For example, RadioButton can be checked.

android:state_ Checked. For example, a RadioButton can be checked.

android:state_ Enabled can accept touch or click events

android:state_ Activated is activated

android:state_ window_ focused

Whether the application is in the foreground. When a notification bar is pulled down or a dialog box pops up, the application is not in the foreground

Note: if there are multiple items, the program will automatically match from top to bottom, and the first matching will be applied. (not by best bet)

If an item does not have any state description, it can be matched by any state.

----------------------------------Item attribute tag------------------------------

The above is the Android custom button control that Xiaobian introduced to you. Click to change color. I hope it will help you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>