\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. spoj 694 求一个字符串中不同子串的个数

    SPOJ Problem Set (classical) 694. Distinct Substrings Problem code: DISUBSTR Given a string, we need ...

  2. asp.net mvc easyui datagrid分页

    提到 asp.net mvc 中的分页,很多是在用aspnetpager,和easyui datagrid结合的分页却不多,本文介绍的是利用easyui 中默认的分页控件,实现asp.net mvc分 ...

  3. WebApi接口传参不再困惑(4):传参详解

    前言:还记得刚使用WebApi那会儿,被它的传参机制折腾了好久,查阅了半天资料.如今,使用WebApi也有段时间了,今天就记录下API接口传参的一些方式方法,算是一个笔记,也希望能帮初学者少走弯路.本 ...

  4. Vue 中的生命周期和钩子函数

    生命周期: beforeCreate:el 和 data 并未初始化 (此方法不常用) created:完成了 data 数据的初始化,el的初始化未完成.用来发送ajax beforeMount:( ...

  5. SQL Server 创建和使用索引

    创建索引: (1)在SQL Server Management Studio中,选择并右击要创建索引的表,从弹出菜单中选择“设计”,打开表设计器.右键单击表设计器,从弹出菜单中选择“索引/键”命令,打 ...

  6. 调试JDK1.8源码的方法

    背景 在学习JDK源码的时候,免不了需要调试JDK的源码. 比如:想理解ConcurrentHashMap的put(K k, V v)方法,JDK自带的rt.jar文件是支持断点调试,但是却看不到变量 ...

  7. AAtitit.随时间变色特效 ---包厢管理系统的规划titit.随

    Atitit.随时间变色特效 ---包厢管理系统的规划 1 流程滴定仪 定义的参数 颜色.位置(开始值,结束值,当前比值) >>返回数值 可以后期处理转成双位16进制码 分别定义复合颜色的 ...

  8. PCIe to AXI Translation——PCIe 内存空间到AXI内存空间的转换

    PCIe to AXI Translation——PCIe 内存空间到AXI内存空间的转换 UltraScale系列芯片包含PCIe的Gen3 Integrated Block IP核在内的多种不同功 ...

  9. Pedometer_forAndroid

    https://github.com/Nicky213Zhang/Pedometer_forAndroid 自行封装了一个计步器控件,采用:计步传感器Sensor.TYPE_STEP_COUNTER计 ...

  10. yii2 RESTful API Develop

    参考文档:http://www.yiiframework.com/doc-2.0/guide-rest.html 以 DB 中的 news 表为例创建该资源的 RESTful API,最终的测试通过工 ...