单选按钮组在某些Android设备上显示不好

问题描述:

请告诉我单选按钮组或单选按钮xml代码中存在哪些问题?单选按钮圈可以在“HTC Sensation”等设备的文本中获得。我不知道什么是问题。请帮我...单选按钮组在某些Android设备上显示不好

这个链接是HTC感觉的画面: https://www.dropbox.com/s/7gjvn09kplv5zqf/HTC%20Sensation.jpg?dl=0

而这一次是模拟器的画面: https://www.dropbox.com/s/tdnpc5vfdf9l1n9/Simulator.png?dl=0

<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" > 

     <TextView 
      android:id="@+id/TextView01" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="20dp" 
      android:layout_marginTop="10dp" 
      android:paddingLeft="10dp" 
      android:paddingRight="10dp" 
      android:text="@string/dialog_choose_music" 
      android:textColor="#ffffff" 
      android:textSize="18sp" /> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" > 

      <RadioGroup 
       android:id="@+id/selectMusicRadioGroup" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/between_games_timer" 
       android:orientation="vertical" > 

       <RadioButton 
        android:id="@+id/silent" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginBottom="3dp" 
        android:background="@drawable/bg_color_selector" 
        android:checked="true" 
        android:ellipsize="end"       
        android:tag="silent" 
        android:maxLines="1" 
        android:paddingBottom="15dp" 
        android:paddingLeft="10dp" 
        android:paddingRight="10dp" 
        android:paddingTop="15dp" 
        android:singleLine="true" 
        android:text="@string/silent" 
        android:textColor="#ffffff" 
        android:textSize="16sp" > 
       </RadioButton> 

       <RadioButton 
        android:id="@+id/myMusic" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginBottom="3dp" 
        android:background="@drawable/bg_color_selector" 
        android:ellipsize="end" 
        android:tag="my_music" 
        android:maxLines="1" 
        android:paddingBottom="15dp" 
        android:paddingLeft="10dp" 
        android:paddingRight="10dp" 
        android:paddingTop="15dp" 
        android:singleLine="true" 
        android:text="@string/custom_music" 
        android:textColor="#ffffff" 
        android:textSize="16sp" > 
       </RadioButton> 
      </RadioGroup> 
     </LinearLayout> 
</LinearLayout> 

论单选按钮和复选框某些设备填料根本不支持。 Android在内部使用padding属性来放置文本和图片,以便改变填充自己将其混淆。

取消填充并在包含布局上使用边距。

+1

遗憾的是它没有解决...... :( – 2014-09-13 15:22:42

您用于RadioButton的“填充”属性仅适用于文本。此外,Android将RadioButton/CheckBox的圆视为​​可绘制的。 (你可以看到有drawableTop,drawableBottom,...在一个单选按钮中)。

因此,为了圆上应用填充,你应该使用“drawablePadding”属性,如下所示:

<RadioButton 
       android:id="@+id/myMusic" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="3dp" 
       android:drawablePadding="10dp" />