RadioButton ---- 样式效果切换

\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 ---- 样式效果切换的更多相关文章
- 利用target的特性,可以实现纯css的tab效果切换
基础知识: :target起作用的是href连接到的位置 如 <a href="#tab1">tab1</a> <div id="tab1& ...
- Android RadioButton 语言无法切换问题
1.Dialog在不退出界面的情况下,RadioButton在语言切换时,无法匹配系统语言的问题: 解决办法为:在RadioButton添加属性 android:saveEnabled="f ...
- wpf radiobuttong 去前面的圆点, 自定义radiobutton样式
自定义radiobutton样式代码: <windows.Resources> <LinearGradientBrush x:Key="CheckRadioFillNorm ...
- dialog 中装listview并让每一个item分隔悬空,并具有radiobutton的效果
先上图 两个关键地方,一是让dialog全透明,二是让listitem分开. 首先定义一个自定义的dialog 布局文件,这个只是包含一个listview而已 <?xml version=&qu ...
- 转:android 自定义RadioButton样式
http://gundumw100.iteye.com/blog/1146527 上面这种3选1的效果如何做呢?用代码写? 其实有更简单的办法,忘了RadioButton有什么特性了吗? 我就用Ra ...
- vue页面切换效果(slide效果切换)
最近碰到一个需求,单页应用里面页面切换的效果需要做成跟轮播图滑动slide一样,让这个页面在切换时感觉是一个页面.反复琢磨的vue里面的transition,最终将实现的核心代码贴出来.这里实现的是上 ...
- WPF 自定义RadioButton样式
一.RadioButton基本样式 RadioButton基本样式包含两种状态,这里也是使用两张图片来代替两种状态,当然你也可以通过IconFont或Path来替换这两种状态. 效果如下: 样式代码如 ...
- Android 自定义RadioButton样式
上面这种3选1的效果如何做呢?用代码写? 其实有更简单的办法,忘了RadioButton有什么特性了吗? 我就用RadioButton实现了如上效果,其实很简单的. 首先定义一张background ...
- 纯css3艺术文字样式效果代码
效果:http://hovertree.com/texiao/css3/1/ 本效果主要使用text-shadow实现.参考:http://hovertree.com/h/bjaf/css3_text ...
随机推荐
- ubuntu卸载第三方库
下面以pcl和opencv为例进行说明. 参考资料: https://www.cnblogs.com/txg198955/p/5990295.html ubuntu卸载opencv并重装opencv ...
- Hibernate配置C3P0连接池
引入C3PO包 在hibernate.cfg.xml文件中配置 <!-- 数据库连接池的使用 --> <!-- 选择使用C3P0连接池 --> <property nam ...
- vpngate 的使用
第一次为小日本打广告.. .我仅仅想仰天大喊..玛的戈壁. .. 竟然活到这个份上了...想出去看看的往下看.. vpngate 下载: http://pan.baidu.com/s/1hq5x3Ly ...
- 【转载】Java 日常开发 - 常见异常
转自 http://blog.sina.com.cn/s/blog_ab345e5d01010zaq.html 算术异常类:ArithmeticExecption 空指针异常类:NullPointer ...
- 点滴积累【other】---存储过程修改表的所有字段(sql)
USE [QG_Mis24] GO /****** Object: StoredProcedure [dbo].[p_set] Script Date: 07/11/2013 17:05:38 *** ...
- 电脑不识别USB blaster驱动问题
电脑不识别USB blaster,如下图: 解决办法:手动更新 http://zhidao.baidu.com/link?url=snVT__AsbtmQ4U5EBVN05Yrgv1TPv7AdVYe ...
- DirectShow中写push模式的source filter流程 + 源码(内附具体凝视)
尽管网上已有非常多关于DirectShow写source filter的资料.只是非常多刚開始学的朋友总说讲的不是非常清楚(可能当中作者省略了很多他觉得简 单的过程).读者总希望看到象第一步怎么做,第 ...
- Django--ORM基础
ORM(映射关系) 映射关系: 表名 <-------> 类名 字段 <-------> 属性 表记录 <------->类实例对象 创建表(建立模型) 在Djan ...
- tensorflow之损失函数
#coding:utf-8 __author__ = 'similarface' import tensorflow as tf sess=tf.Session() #max(features, 0) ...
- JVM-String常量池与运行时常量池
Start with JVM 周志明先生著-<深入理解Java虚拟机>,书买回来好几天了,但是最近才准备开始搞一搞了(哭瞎…..).首先是第一章的Java以及JVM发展历史,大概知道了现行 ...