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",否则还是会有一个可以选择的圈圈出现

更多相关文章

  1. Android中的自定义主题和样式
  2. Android 命名空间和自定义属性
  3. Android 自定义View(API解析+Demo)
  4. 自定义控件与Handler
  5. android的自定义弹出窗
  6. Android系统自带样式(android:theme)(stephen830的博客)
  7. android 自定义对话框
  8. Android jni系统变量、函数、接口定义汇总

随机推荐

  1. AngularJS:登录cookie过期时如何注销
  2. 调用另一个html页面后,选择列表值不会保持
  3. 怎么javascript读取本地文件中的数据,并显
  4. RequireJS中的命名模块与未命名模块
  5. 更新:在Gulpfile中带有postCSS和Babel的
  6. 推json敲出可观察的数组
  7. Angularjs在ng-repeat中找到最后一个可见
  8. Angularjs:如何将范围变量传递给指令?
  9. IE 浏览器各个版本 JavaScript 支持情况
  10. 当页面上有多个按钮时,按钮样式在页面加载