三种方法
1.使用XML文件进行定义 res/drawable/radio.xml
01 |
<? xml
version = "1.0"
encoding = "utf-8" ?>
|
02 |
< selector
xmlns:android = "http://schemas.android.com/apk/res/android" >
|
05 |
android:state_checked = "false"
|
06 |
android:drawable = "@drawable/tabswitcher_long"
/>
|
09 |
android:state_checked = "true"
|
10 |
android:drawable = "@drawable/tabswitcher_short"
/>
|
在布局文件中使用
7 |
android:background = "@drawable/radio"
|
android:button="@null" 去除RadioButton前面的圆点
android:background="@drawable/radio" 使用定义的样式 2.在JAVA代码中定义
2 |
public
boolean onTouchEvent(MotionEvent event) {
|
3 |
if (event.getActionMasked() == MotionEvent.ACTION_DOWN){
|
4 |
this .setBackgroundResource(com.wxg.tab.R.drawable.main_bg);
|
5 |
} else
if (event.getActionMasked()== MotionEvent.ACTION_DOWN) {
|
6 |
this .setBackgroundResource(com.wxg.tab.R.drawable.hui);
|
8 |
return
super .onTouchEvent(event);
|
去除RadioButton前面的圆点adioButton.setButtonDrawable(android.R.color.transparent);
3.使用XML文件定义,在JAVA代码中使用
radioButton.setBackgroundResource(R.drawable.radio);调用
分享到:
相关推荐
android 自定义RadioButton的样式android 自定义RadioButton的样式
三种方法实现Android定制RadioButton样式:使用XML文件进行定义/在JAVA代码中定义等等,感兴趣的朋友可以参考下,希望可以帮助到你
自定义android RadioButton样式,代码说明地址:http://blog.csdn.net/jason_996/article/details/62889374
android 自定义 单选按钮 radioButton
原来在用android的TabHost生成的选项卡时有一定的局限性,它不能很好地用布局控制,而我转而采用android的RadioButton来生成选项卡并实现选项卡功能,并且这个代码还实现了ViewFlipper实现选项卡根据手势左右滑动的...
android中RadioButton的图标在左边,文字在右边,如何实现文字在左边,图标在右边? 第一步:将RadioButton自带的图标隐藏, 第二步:在隐藏图标的右边添加系统的图标 第三步:在隐藏图标的位置显示文字. 具体参考: ...
<com.triman.android.ui.MyRadioButton android:id="@+id/rb_sys_set" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:button="@null" android:...
最近写项目有个需求是单选框必须改成设计要的样子,然后再网上找了好久,自己调试了一下,就好了
android组件 RadioButton,CheckBox,Toast简单介绍,
android Menu 和 RadioGroup RadioButton的用法
WPF 实现RadioButton样式两种方式:1资源样式 2代码调用资源样式 ,vs2010
Android自定义RadioButton和CheckBox样式,重写RadioButton的onDraw()方法,实现颜色选择器效果。
tabhost原效果并不理想 这里利用button 改善
支持使用selector的自定义RadioButton
Android_实例_利用RadioButton实现分类筛选
android 自定义radiobutton图片样式
android自定义RadioButton,可用于竖直方向的tabhost组件的自定义设计,实现了tabWiget的效果。
安卓Android源码——(RadioButton与监听).zip
android代码实现动态加载Radiobutton