The style and theme selector for Android learning notes

Source: Internet
Author: User

(1) Layout file

<relativelayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http// Schemas.android.com/tools "android:layout_width=" match_parent "android:layout_height=" Match_parent "Android:paddi ngbottom= "@dimen/activity_vertical_margin" android:paddingleft= "@dimen/activity_horizontal_margin" Android: paddingright= "@dimen/activity_horizontal_margin" android:paddingtop= "@dimen/activity_vertical_margin" tools: Context= ". Mainactivity "> <button android:id=" @+id/button1 "android:layout_width=" Wrap_content "Androi         d:layout_height= "Wrap_content" android:layout_alignparentbottom= "true" android:layout_alignparentleft= "true" Android:layout_marginbottom= "189DP" android:layout_marginleft= "55DP" android:textcolor= "@color/butto N_selector "android:text=" Test Color list status "/></relativelayout>


Need to use inside the button: android:textcolor= "@color/button_selector"

(2) You need to create a color folder in the Res directory

The contents of the Button-selector file are as follows:

<?xml version= "1.0" encoding= "Utf-8"? ><selector xmlns:android= "http://schemas.android.com/apk/res/ Android ">    <item android:state_pressed=" true "android:color=" #ffff0000 "/>    <item Android:state_ Focused= "true" android:color= "#ff0000ff"/>    <item android:color= "#ff000000"/></selector>


Other files do not change, the default can be


The style and theme selector for Android learning notes

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.