Android app development (you must know the property value under Android selector)

Source: Internet
Author: User

 

Add a file in the Res/drawable folder, which sets the image trigger status. You can set state_pressed, state_checked, state_pressed, state_selected, state_focused, state_enabled, and other statuses:

Android: state_pressed

Boolean. "True" if this item shocould be used when the object is pressed (such as when a button is touched/clicked); "false" if this item shoshould be used in the default, non-pressed state.

If it is true, the image is displayed when it is clicked. If it is false, it is displayed by default when it is not pressed.

Android: state_focused

Boolean. "True" if this item shocould be used when the object is focused (such as when a button is highlighted using the trackball/D-pad ); "false" if this item shocould be used in the default, non-focused state.

True: The value is displayed when the focus is obtained. False: The default value is displayed when the focus is not obtained.

Android: state_selected

Boolean. "True" if this item shocould be used when the object is selected (such as when a tab is opened); "false" if this item shocould be used when the object is not selected.

True: The image is displayed when it is selected; false: The image is displayed when it is not selected.

Android: state_checkable

Boolean. "True" if this item shocould be used when the object is checkable; "false" if this item shocould be used when the object is not checkable. (only useful if the object can transition between a checkable and non-checkable widget .)

True: The image is displayed when the checkbox function is enabled. False: The image is displayed when the checkbox function is unavailable.

Android: state_checked

Boolean. "True" if this item shocould be used when the object is checked; "false" if it shocould be used when the object is un-checked.

True: The image is displayed when the checkbox is selected; false: The image is displayed when the checkbox is selected.

Android: state_enabled

Boolean. "True" if this item shocould be used when the object is enabled (capable of processing touch/click events); "false" if it shocould be used when the object is disabled.

True: The image is displayed when the component is available; false: The image is displayed when the component is unavailable.

Android: state_window_focused

Boolean. "True" if this item shocould be used when the application window has focus (the application is in the foreground ), "false" if this item shocould be used when the application window does not have focus (for example, if the notification shade is pulled down or a dialog appears ).

True: displays the image when the activity gets the focus at the beginning; false: displays the image when the focus is not at the beginning.

<? XML version = "1.0" encoding = "UTF-8"?>
<Selector xmlns: Android = "http://schemas.android.com/apk/res/android">

<Item Android: state_pressed = "true"

Android: drawable = "@ drawable/button_pressed"/> <! --
Pressed -->

<Item Android: state_focused = "true"

Android: drawable = "@ drawable/button_focused"/> <! --
Focused -->

<Item Android: drawable = "@ drawable/button_normal"/> <! --
Default
-->
</Selector>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.