[Android]定制RadioButton样式
来源:互联网 发布:长虹电视有线网络设置 编辑:程序博客网 时间:2024/04/20 18:42
三种方法
1.使用XML文件进行定义 res/drawable/radio.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/tabswitcher_long" /><!--选中-> <item android:state_checked="true" android:drawable="@drawable/tabswitcher_short" /> </selector>
在布局文件中使用
<RadioGroup ...><RadioButton ...android:button="@null"android:background="@drawable/radio"/></RadioGroup>
android:button="@null" 去除RadioButton前面的圆点
android:background="@drawable/radio" 使用定义的样式
2.在JAVA代码中定义
@Override public boolean onTouchEvent(MotionEvent event) { if(event.getActionMasked() == MotionEvent.ACTION_DOWN){ this.setBackgroundResource(com.wxg.tab.R.drawable.main_bg); }else if(event.getActionMasked()== MotionEvent.ACTION_DOWN) { this.setBackgroundResource(com.wxg.tab.R.drawable.hui); } 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样式
- Android 定制RadioButton样式
- Android 定制RadioButton样式
- 三种方法实现Android定制RadioButton样式
- Android定制RadioButton样式三种实现方法
- Android定制RadioButton样式三种实现方法
- RadioButton - android 自定义RadioButton样式
- android 自定义RadioButton样式
- Android UI Radiobutton 样式
- android 自定义RadioButton样式
- Android 自定义RadioButton样式
- Android自定义RadioButton样式
- android 自定义RadioButton样式
- android 自定义RadioButton样式
- android 自定义RadioButton样式
- android 自定义RadioButton样式
- 互联网小知识
- PKU 2528 线段树
- Web UI 自动化测试实践
- 下载android 4.0源码
- android 资源访问
- [Android]定制RadioButton样式
- 学生成绩管理系统设计
- 我是一只IT小小鸟 书摘
- Blackfin BF537 的 DMA模式 UART通信程序简例
- dsp 一些术语
- 判断有向图是否有环 、环的个数以及环中元素
- initialize Class- consturctors
- Java数组声明、创建、初始化
- Qt笔记-1