2012-03-30 57 views
2

我正在尝试使用收音机小部件进行小组活动。我的问题是,我似乎不能删除与单选按钮随附的扬声器图标任何帮助将非常感谢。自定义收音机组

http://img715.imageshack.us/img715/3131/helpnj.png

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" > 


<RadioGroup 
    android:id="@+id/radioGroup1" 
    android:layout_width="match_parent" 
    android:layout_height="55dp" android:background="@drawable/tilte2"> 



    <RelativeLayout 
     android:id="@+id/relativeLayout1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 


     <RadioButton 
      android:id="@+id/radioButton1" 
      android:layout_width="105dp" 
      android:layout_height="fill_parent" 
      android:layout_alignParentRight="true" 
      android:layout_centerVertical="true" 
      android:background="@null"/> 

     <RadioButton 
      android:id="@+id/radioButton3" 
      android:layout_width="105dp" 
      android:layout_height="fill_parent" 
      android:layout_alignParentLeft="true" 
      android:layout_centerVertical="true" 
      android:background="@null"/> 

     <RadioButton 
      android:id="@+id/radioButton2" 
      android:layout_width="105dp" 
      android:layout_height="fill_parent" 
      android:layout_alignParentTop="true" 
      android:layout_centerHorizontal="true" 
      android:background="@null"/> 

    </RelativeLayout> 

</RadioGroup> 

回答

12

如果您需要自定义的单选按钮看看..

创建在绘制的文件夹中选择XML(radio_btn_selector.xml)。

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
<item android:drawable="@drawable/pressed_image" 
    android:state_pressed="true"/> 
<item android:drawable="@drawable/checked_image" 
    android:state_checked="true"/> 
<item android:drawable="@drawable/focused_image" 
    android:state_focused="true" /> 
<item android:drawable="@drawable/default_image" /> 
</selector> 

现在使用选择器作为单选按钮中的按钮类型。

<RadioButton 
      android:id="@+id/radioButton2" 
      android:layout_width="105dp" 
      android:layout_height="fill_parent" 
      android:layout_alignParentTop="true" 
      android:layout_centerHorizontal="true" 
      android:background="@null" 

android:button="@drawable/radio_btn_selector" />

+0

不错的一个!正确答案+1 – Zoombie 2013-04-22 07:13:37

0

为什么不使用一个切换按钮呢? 没有图标的RadioButton就像一个ToggleButton :)