\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. mybatis学习知识

    目录 1,目录 2,介绍 3,快速入门 4,配置XML 5,xml文件映射 6,动态sql 7,java api 8,Statement Builders 9,日志 1,介绍 1.1 介绍 1.1.1 ...

  2. 在项目中增加自定义icon图标

    以MUI框架为例,内容来自于MUI官网. mui如何增加自定义icon图标 mui框架遵循极简原则,在icon图标集上也是如此,mui仅集成了原生系统中最常用的图标:其次,mui中的图标并不是图片,而 ...

  3. javascript删除数组中的某个元素-----拓展Array 原型方法

    Array.prototype.remove = function (dx) { if(isNaN(dx) || dx > this.length) { return false; } var  ...

  4. Android错误之--activity_main cannot be resolved or is not a field

    一般在copy别人的项目中会easy出现本错误,截图例如以下:

  5. mysql数据库分库备份脚本

    mysql数据库分库备份脚本 版本1 for dbname in `mysql -uroot -poldboy123 -e "show databases;" |grep -Evi ...

  6. 从零搭建Web网站

    前言 工作也有几多年了,无论是身边遇到的还是耳间闻到的,多多少少也积攒了自己的一些经验和思考,当然,博主并没有太多接触高大上的分布式架构实践,相对比较零碎,随时补充.俗话说得好,冰冻三尺非一日之寒,滴 ...

  7. Unity 扩展编辑器

    扩展Inspector界面 继承自Editor,添加CustomEditorAttribute,传入定制的类型 定制显示的类型要求: 类型中所有的public 字段都会自动暴露给Inspector编辑 ...

  8. 标准差分进化算法matlab程序实现(转载)

    标准差分进化算法matlab程序实现 自适应差分演化算法方面的Matlab和C++代码及论文 差分进化算法 DE-Differential Evolution matlab练习程序(差异演化DE) [ ...

  9. 数据库设计(二)Introduction to Database Design

    原文链接:http://www.datanamic.com/support/lt-dez005-introduction-db-modeling.html Introduction to Databa ...

  10. Unity3D中uGUI事件系统简述及使用方法总结

    Unity3D的uGUI系统的将UI可能触发的事件分为12个类型,即EventTriggerType枚举的12个值.如下图所示: 先以PointerClick为例.这个是用于某点点击事件.其他事件都可 ...