Android checkbox background style and color values for button click Effects

Source: Internet
Author: User

1 Use color values (without pictures) to achieve the click effect of the button:
Color.xml
<color name= "Head_color" > #836FFF </color>
<color name= "Information_title_color" > #666666 </color>
<color name= "List_bg_color" > #FFF4F4F4 </color>
<color name= "List_focus_color" > #bdbdbd </color>

<drawable name= "F4f4f4" > #f4f4f4 </drawable>
<drawable name= "camera_back_press" > #1b1b1b </drawable>
<drawable name= "Camera_back_default" > #2f2f2f </drawable>


Files in drawable
<?xml version= "1.0" encoding= "Utf-8"?>
<selector xmlns:android= "Http://schemas.android.com/apk/res/android" >

<item android:drawable= "@drawable/camera_back_default" android:state_pressed= "false" ></item>
<item android:drawable= "@drawable/camera_back_press" android:state_pressed= "true" ></item>

</selector>



2 Checkbox,radiobutton,star Set button background image and click Effect

One selector Click Effect
<selector xmlns:android= "Http://schemas.android.com/apk/res/android" >

<item android:drawable= "@drawable/checkbox_click_true" android:state_checked= "true"/>
<item android:drawable= "@drawable/checkbox_default" android:state_checked= "false"/>
<item android:drawable= "@drawable/checkbox_default" ></item>
<item android:drawable= "@drawable/checkbox_click_false" android:state_checkable= "false" ></item>

</selector>

Set style for a build

<style name= "Mycheck_box" parent= "@android: Style/widget.compoundbutton.checkbox" >
<item name= "Android:button" > @drawable/check_box_selector</item>
<item name= "Android:paddingleft" >5.0dip</item>
<item name= "Android:textsize" >14sp</item>
</style>

You must set the parent as the component for which you want to set the effect.

Item must reference the button element and set the resource file to the selector effect

Item can set the spacing and text size between the button and the text, and so on

Three in the layout file, the component sets the Style property
<checkbox
Android:id= "@+id/checkbox1"
style= "@style/mycheck_box"
Android:layout_width= "Match_parent"
android:layout_height= "Wrap_content"
android:layout_weight= "1"
android:text= "Football"
android:paddingleft= "18DP"
Android:textcolor= "@color/black_color"

Android:textsize= "14sp"/>


EditText, select content when clicked.

The first thing to do is to implement the Click event interface. Do the following in the listening process:

mEdtCount.setText ( Medtcount.gettext (). toString ());//Add this sentence after the implementation effect
            spannable content = Medtcount.gettext ();
            selection.selectall (content);

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.