当前位置:操作系统 > 安卓/Android >>

android-RadioButton背景使用图片

1.定义drawable样式
 
drawable/style_button_subject.xml如下:
 
<?xml version="1.0" encoding="utf-8"?>
<selector
    xmlns:android="http://schemas.android.com/apk/res/android">
 
    <item android:state_checked="false" android:drawable="@drawable/buttonsubject_1"/>
    <item android:state_checked="true"  android:drawable="@drawable/buttonsubject_2"/>
    <item android:state_selected="true"  android:drawable="@drawable/buttonsubject_2"/>
    <item android:state_pressed="true"  android:drawable="@drawable/buttonsubject_2"/>
 
</selector>
 
 
 
2.为RadioButton设置drawable样式
 
        <RadioButton
        android:id="@+id/buttonsubject11"
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_weight="85"
        android:button="@null"
        android:gravity="center"
        android:textSize="@dimen/buttonSubjectTextSize"
        android:background="@drawable/style_button_subject"
        />
 
 
 
这样就得到了可以拉伸的图片作为背景的RatioButton
 
注意要设置android:button="@null",否则还是会有一个可以选择的圈圈出现
补充:移动开发 , Android ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,