From:http://blog.csdn.net/sunnyfans/article/details/7901592?utm_source=tuicool&utm_medium=referral
AndroidHow to set RadioButton to the right of the text, the icon on the left???
Workaround:
The first step:
android:button= "@null" this statementThe original system'sRadioButton icons to hide them.
Step Two:
android:drawableright= "@android:d rawable/btn_radio" statement
Add a system-btn_radio icon to the right of the original icon, and I think RadioButton isThe btn_radio icon is encapsulated.
<?xml version= "1.0" encoding= "Utf-8"?>
<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
android:orientation= "vertical" >
<radiogroup
android:id= "@+id/radiogroup1"
android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
<radiobutton
android:id= "@+id/button1"
android:layout_width= "Match_parent"
android:layout_height= "Wrap_content"
android:button= "@null"
android:checked= "true"
android:drawableright= "@android:d rawable/btn_radio"
android:paddingleft= "10DP"
android:text= "RadioButton"/>
<radiobutton
android:id= "@+id/button2"
android:layout_width= "319DP"
android:layout_height= "Wrap_content"
android:button= "@null"
android:drawableright= "@android:d rawable/btn_radio"
android:paddingleft= "10DP"
android:text= "RadioButton"/>
</RadioGroup>
</LinearLayout>
Demo Download
http://download.csdn.net/detail/sunnyfans/4521592
attached to the reference website:
http://www.haogongju.net/art/1422253
Summary:
today in the implementation of Radiogroup single-choice, require text on the left, select the icon on the right, and the Android system comes with the Radiogroup is the icon on the left, the text on the right, since I have this demand, encounter this problem, then certainly there are other people have this demand, So there should be a way to implement it. Because the problem has already occurred, the world is in the process of constantly solving the unknown problem of continuous development and progress, namely: demand, the problem is the original driving force of invention and development. Knowledge is born to solve a problem, or to describe a phenomenon. Therefore, no matter what problems encountered in the future, do not fear, since the problem has occurred, that there will be a solution to it, then you need to think about it, think about the environment of the problem, analyze the problem, and then locate the cause of the problem (dichotomy) < first guess, and then prove;Positioning and then thinking about how to solve. Constantly remind yourself to develop the habit of encountering problems, analyzing problems, and then trying to solve problems.
Knowledge Harvesting:
Recognizing the importance of the Android icon, this can be used:
Android:button= "@null" to hide the icon and then use android:drawableright= "@android:d Rawable/btn_radio" to regenerate an icon on the right, then use the android:text= Text content displays text in the location of the hidden icon.
Think again and again:
android:button= "@null"
android:drawableright= "@android:d Rawable/btn_radio
This provides a common approach.
Attached: Demo download
http://download.csdn.net/detail/sunnyfans/4521592
How to set RadioButton to the right of text on Android, icon on the left