Use your own definition checkbox or RadioButton time. Define your own icons and text on different phones to show different pitches. Sometimes not very well controlled, here is my own definition checkbox:
In layout in the following XML:
<checkbox android:id= "@+id/recharge_activity_cb" style= "@style/customcheckboxtheme" android: Layout_width= "Wrap_content" android:layout_height= "wrap_content" android:text= "I have read and allowed" Android: Textcolor= "@color/huoqiulightblackcolor" android:checked= "true" />
Inside a style defined by itself. The style content is:
<!--yourself define the checkbox-- <style name= "Customcheckboxtheme" parent= "@android: style/ Widget.CompoundButton.CheckBox "> <item name=" Android:button "> @drawable/checkbox_style</item> <item name= "Android:paddingleft" > @dimen/dp8</item> </style>
The selected and unchecked pictures are called. Under the drawable:
<?XML version= "1.0" encoding= "Utf-8"? ><selector xmlns:android= "Http://schemas.android.com/apk/res/android" > <item android:state_checked= "true" android:drawable= "@drawable/agree"/> <item android:state _checked= "false" android:drawable= "@drawable/disagree"/> <item android:drawable= "@drawable/disagree"/ ></selector>
Although you can display the desired on some systems by setting paddingleft, some do not.
<item name= "Android:paddingleft" > @dimen/dp8</item>
So the question is, what method can be solved?
Here's how I fix it: using the Checkedtextview control
<checkedtextview android:id= "@+id/recharge_activity_ctv" android:checkmark= "@drawable/checkbox_ Style " android:layout_width=" wrap_content " android:layout_height=" wrap_content " android:checked=" True " />
<textview android:id= "@+id/buy_write_jine_agree_tv" android:layout_width= "Wrap_content" Android : layout_height= "wrap_content" android:text= "I have read and allow" android:textcolor= "@color/huoqiulightblackcolor" android:layout_marginleft= "@dimen/dp3" />
And checkmark is the one in the top drawable. Selected State XML
android:checkmark= "@drawable/checkbox_style"
Then use ischecked () to infer whether the Checkedtextview is selected in the code, and use the toggle () method to set the selected and unchecked effects. So there is no space between the icon and the text, the problem is solved perfectly.
Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.
Android CheckBox RadioButton photo and text spacing issues