先看效果
主要是写一个 color selector
在res/建一个文件夹取名color
res/color/color_radiobutton.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:color="@color/color_text_selected"/>
<!-- not selected -->
<item android:color="@color/color_text_normal"/>
</selector>
程序中就可以直接使用了
//layout/main.xml
<?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/radiogroup_personal_condition"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/radiobutton_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/selector_radio"
android:button="@null"
android:checked="true"
android:gravity="center"
android:text="目录"
android:textColor="@color/color_radiobutton"
android:textSize="@dimen/font_size"
android:textStyle="bold" />
<RadioButton
android:id="@+id/radiobutton_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/selector_radio"
android:button="@null"
android:gravity="center"
android:text="书签"
android:textColor="@color/color_radiobutton"
android:textSize="@dimen/font_size"
android:textStyle="bold" />
</RadioGroup>
</LinearLayout>
分享到:
相关推荐
android 自定义RadioButton的样式android 自定义RadioButton的样式
android 自定义 单选按钮 radioButton
支持使用selector的自定义RadioButton
android自定义RadioButton,可用于竖直方向的tabhost组件的自定义设计,实现了tabWiget的效果。
Android自定义RadioButton和CheckBox样式,重写RadioButton的onDraw()方法,实现颜色选择器效果。
使用VS2005开发,VS2005及以上版本都可以使用
自定义android RadioButton样式,代码说明地址:http://blog.csdn.net/jason_996/article/details/62889374
android 高仿微信底部菜单 用自定义的radiobutton和radiogroup实现,能实现气泡数字的效果,viewpager+自定义的radiobutton+radiogroup
android充值demo 自定义editview自定义radiobutton
andrdoid自定义RadioButton ,设置选中框与字体的距离
仿美团支付自定义radiobutton。样式可以自己修改。 仿美团支付自定义radiobutton。样式可以自己修改。 仿美团支付自定义radiobutton。样式可以自己修改。
最近写项目有个需求是单选框必须改成设计要的样子,然后再网上找了好久,自己调试了一下,就好了
自实现模仿美图的支付功能的单选按钮的操作,具有自定义的布局,具体内容请见http://blog.csdn.net/js931178805/article/details/8823306
.net compact framework 自定义Radiobutton
Android 自定义RadioGroup布局,修改源码自定义控件。RadioGroup组里面可以包含不同的布局,布局里面RadioButton。用了递归查找RadioButton。欢迎下载示例代码。
这是一个自定义单选框的例子,可以参考一下。
类似美团支付方式选择自定义RadioButton,代码可直接应用于项目
android中RadioButton的图标在左边,文字在右边,如何实现文字在左边,图标在右边? 第一步:将RadioButton自带的图标隐藏, 第二步:在隐藏图标的右边添加系统的图标 第三步:在隐藏图标的位置显示文字. 具体参考: ...