The use of Chekbox we do not have to say, is a very old control, how similar to the RadioButton, this thing because I have not yet written out, may later refer to other Lib to write. By the way, if your app is compiled in 5.0, then when you use a traditional checkbox, you'll find that the checkbox runs on the lower version of the machine and it's different from what it used to be, although it's not animated, but looks like more than 5.0 checkboxes.
Minimum size
X 48
Open source lib for different screens to do a different size of the tick picture, should be able to meet the requirements of HD screen. As for the unavailable state has not yet done, in fact, it is inherited under the Isenable () method, but because of the effect I am not very satisfied, so just try, not really put out.
First, import into their own projects
To use this control or to add support for open source projects, open source project address:
I maintain: https://github.com/shark0017/MaterialDesignLibrary
Original version: Https://github.com/navasmdc/MaterialDesignLibrary
You can choose a download, anyway, two versions are my original author and the fusion of things, the difference is not big.
After adding the Lib support, we can use this control, before we put the layout file or write the namespace.
xmlns:app= "Http://schemas.android.com/apk/res-auto"
< Com.gc.materialdesign.views.CheckBox Android:layout_width = "Wrap_content" android:layout_height= "Wrap_content" android:layout_gravity= "Center_ Horizontal "/>
Since I did not visualize the effect, so in the compiler is not able to display the status in real time, the default is a transparent view. If you want to see a general look at the compiler, you can add a background color to it by background= "#xxxxxx".
Real-World performance:
Ii. setting various properties in the layout file
App:checked= "True" is selected and is not selected by default
Android:background= "#ff0000" sets the color of the checkbox, which is green by default
Android:layout_width= "100DP" setting checkbox the overall size of the view is independent of the box inside. Note the size of the shadow when pressed in the figure
android:layout_height= "100DP"
App:checkboxsize= "40DP" sets the size of the box inside the checkbox
Three, through the code to set various properties
Public classCheckboxtestextendsactionbaractivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.checkbox); CheckBox checkbox=(CheckBox) Findviewbyid (R.ID.CHECKBOX01); Checkbox.setchecked (true);//set the initial selected stateCheckbox.setbackgroundcolor (0xffff0000);//set the color of a checkboxCheckbox.setbackgroundcolor (Getresources (). GetColor (R.color.orange));//Set Background colorCheckbox.setcheckboxsize (35.5f);//set the size of the box//Listen for selected eventsCheckbox.setonchecklistener (NewOnchecklistener () {@Override Public voidOnCheck (BooleanisChecked) { //TODO Auto-generated method stubsSystem.out.println ("isChecked =" +checkbox05.ischecked ()); Toast.maketext (checkboxtest. This, "checkbox status =" +ischecked, 0). Show (); } }); }}
Material Designer's low version compatible implementations (10)--checkbox