·您现在的位置: 云翼网络 >> 文章中心 >> 网站建设 >> app软件开发 >> Android开发 >> Android中设置RadioButton在文字右边的方法实例

Android中设置RadioButton在文字右边的方法实例

作者:佚名      Android开发编辑:admin      更新时间:2022-07-23


<?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"  
  android:layout_marginRight="5dp" 
  android:layout_marginLeft="10dp"> 
 
  <RadioGroup 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > 
 
    <RadioButton 
      android:id="@+id/rb_disable" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:button="@null" 
      android:drawableRight="@android:drawable/btn_radio" 
      android:text="@string/data_romaing_disable" /> 
 
    <RadioButton 
      android:id="@+id/rb_national_romaing_only" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:button="@null" 
      android:drawableRight="@android:drawable/btn_radio" 
      android:text="@string/data_romaing_national_romaing_only" /> 
 
    <RadioButton 
      android:id="@+id/rb_all_network" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:button="@null" 
      android:drawableRight="@android:drawable/btn_radio" 
      android:text="@string/data_romaing_all_network" /> 
  </RadioGroup> 
 
</LinearLayout> 


 想要改变RadioButton 的位置,就先设置默认的图片为null ,在调用对应的方法将图标放在指定的位置