\res\drawable\radio_button_bg.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/raido_button_checked"
android:state_checked="true"/>
<item android:drawable="@android:color/transparent" /> </selector>

\res\values\strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">RadioButtonDemo</string>
<string name="hello_world">Hello world!</string>
<string name="menu_settings">Settings</string>
<string name="radio_button_1">JAVA</string>
<string name="radio_button_2">ASP.NET</string>
<string name="radio_button_3">P H P</string>
</resources>

\res\values\styles.xml

    <style name="RadioButtonStyles">
<item name="android:layout_gravity">center_vertical</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_weight">1</item>
<item name="android:button">@null</item>
<item name="android:background">@drawable/radio_button_bg</item>
<item name="android:gravity">center</item>
</style>

\res\menu\activity_radio_button_demo.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menu_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/menu_settings"/>
</menu>

\res\layout\activity_radio_button_demo.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" > <RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="@drawable/x_proposal_tab_bg"
android:orientation="horizontal" > <RadioButton
android:id="@+id/radio0"
style="@style/RadioButtonStyles"
android:text="@string/radio_button_1" /> <RadioButton
android:id="@+id/radio1"
style="@style/RadioButtonStyles"
android:text="@string/radio_button_2" /> <RadioButton
android:id="@+id/radio2"
style="@style/RadioButtonStyles"
android:text="@string/radio_button_3" />
</RadioGroup> </RelativeLayout>

RadioButtonDemoActivity.java

public class RadioButtonDemoActivity extends Activity {

    @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_radio_button_demo);
} @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_radio_button_demo, menu);
return true;
} }

DEMO下载地址:http://download.csdn.net/detail/androidsj/5865317

RadioButton ---- 样式效果切换的更多相关文章

  1. 利用target的特性,可以实现纯css的tab效果切换

    基础知识: :target起作用的是href连接到的位置 如 <a href="#tab1">tab1</a> <div id="tab1& ...

  2. Android RadioButton 语言无法切换问题

    1.Dialog在不退出界面的情况下,RadioButton在语言切换时,无法匹配系统语言的问题: 解决办法为:在RadioButton添加属性 android:saveEnabled="f ...

  3. wpf radiobuttong 去前面的圆点, 自定义radiobutton样式

    自定义radiobutton样式代码: <windows.Resources> <LinearGradientBrush x:Key="CheckRadioFillNorm ...

  4. dialog 中装listview并让每一个item分隔悬空,并具有radiobutton的效果

    先上图 两个关键地方,一是让dialog全透明,二是让listitem分开. 首先定义一个自定义的dialog 布局文件,这个只是包含一个listview而已 <?xml version=&qu ...

  5. 转:android 自定义RadioButton样式

    http://gundumw100.iteye.com/blog/1146527  上面这种3选1的效果如何做呢?用代码写? 其实有更简单的办法,忘了RadioButton有什么特性了吗? 我就用Ra ...

  6. vue页面切换效果(slide效果切换)

    最近碰到一个需求,单页应用里面页面切换的效果需要做成跟轮播图滑动slide一样,让这个页面在切换时感觉是一个页面.反复琢磨的vue里面的transition,最终将实现的核心代码贴出来.这里实现的是上 ...

  7. WPF 自定义RadioButton样式

    一.RadioButton基本样式 RadioButton基本样式包含两种状态,这里也是使用两张图片来代替两种状态,当然你也可以通过IconFont或Path来替换这两种状态. 效果如下: 样式代码如 ...

  8. Android 自定义RadioButton样式

     上面这种3选1的效果如何做呢?用代码写? 其实有更简单的办法,忘了RadioButton有什么特性了吗? 我就用RadioButton实现了如上效果,其实很简单的. 首先定义一张background ...

  9. 纯css3艺术文字样式效果代码

    效果:http://hovertree.com/texiao/css3/1/ 本效果主要使用text-shadow实现.参考:http://hovertree.com/h/bjaf/css3_text ...

随机推荐

  1. 【VBA编程】08.数组

    [数组简介]数组其实就是一组相同类型的数据的有序集合,其形象表示就像线性表.在存储数据的时候,首先在内存中分配一个连续的存储空间,将各个元素按顺序存放在连续的存储单元格中.[定义静态数组]Dim 数据 ...

  2. nutch中bin/crawl和bin/nutch crawl的用法(转)

    针对上一篇文章中出现的问题:Command crawl is deprecated, please use bin/crawl instead错误信息,今天在官网上查阅了一下,进行了总结. 官网lin ...

  3. 【微信小程序】退款功能教程(含申请退款和退款回调)

    1.一定要区分小程序和公众号的退款,唯一的区别就是 appid不一样,其他的都是一样的. 不废话,直接写代码了啊. 放大招!!! 然后,需要注意的:最好是把证书放在下面的php的同级或者下级. 证书的 ...

  4. Linux 添加开机启动项的三种方法

    linux 添加开机启动项的三种方法. (1)编辑文件 /etc/rc.local 输入命令:vim /etc/rc.local 将出现类似如下的文本片段: #!/bin/sh## This scri ...

  5. C语言-二进制技巧

    打开位: flags = flags | MASK 要打开的位为 1 关闭位: flags = flags & ~MASK 要关闭的位为 1 转置位: flags = flags ^ MASK ...

  6. golang使用sqlite

    安装问题 在import sqlite的时候,golang build 出现以下错误, exec: "gcc": executable file not found in %PAT ...

  7. centos7(vmware install) 安装EMQ注意事项 ---控制台远程访问

    若想远端访问控制台,需打开对于端口 TCP 服务端口占用 EMQ 2.0 消息服务器默认占用的 TCP 端口包括: 1883 MQTT 协议端口 8883 MQTT/SSL 端口 8083 MQTT/ ...

  8. 创建cocos2d-x+lua项目

    1>     创建cocos2d-x+lua项目 进入到cocos2d-x-2.1.5\tools\project-creator文件夹运行下面命令: python create_project ...

  9. C语言第十一回合:预处理命令的集中营

    C语言第十一回合:预处理命令的集中营   [学习目标]   1.         宏定义 2.         文件包括"处理 3.         条件编译 预处理命令:能够改进程序设计的 ...

  10. poj 1475 Pushing Boxes 推箱子(双bfs)

    题目链接:http://poj.org/problem?id=1475 一组测试数据: 7 3 ### .T. .S. #B# ... ... ... 结果: //解题思路:先判断盒子的四周是不是有空 ...