- 浏览: 5774878 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (890)
- WindowsPhone (0)
- android (88)
- android快速迭代 (17)
- android基础 (34)
- android进阶 (172)
- android高级 (0)
- android拾遗 (85)
- android动画&效果 (68)
- Material Design (13)
- LUA (5)
- j2me (32)
- jQuery (39)
- spring (26)
- hibernate (20)
- struts (26)
- tomcat (9)
- javascript+css+html (62)
- jsp+servlet+javabean (14)
- java (37)
- velocity+FCKeditor (13)
- linux+批处理 (9)
- mysql (19)
- MyEclipse (9)
- ajax (7)
- wap (8)
- j2ee+apache (24)
- 其他 (13)
- phonegap (35)
最新评论
-
Memories_NC:
本地lua脚本终于执行成功了,虽然不是通过redis
java中调用lua脚本语言1 -
ZHOU452840622:
大神://处理返回的接收状态 这个好像没有监听到 遇 ...
android 发送短信的两种方式 -
PXY:
拦截部分地址,怎么写的for(int i=0;i<lis ...
判断是否登录的拦截器SessionFilter -
maotou1988:
Android控件之带清空按钮(功能)的AutoComplet ...
自定义AutoCompleteTextView -
yangmaolinpl:
希望有表例子更好。。。,不过也看明白了。
浅谈onInterceptTouchEvent、onTouchEvent与onTouch
先看一下图:
上面这种3选1的效果如何做呢?用代码写?
其实有更简单的办法,忘了RadioButton有什么特性了吗?
我就用RadioButton实现了如上效果,其实很简单的。
首先定义一张background,命名为radio.xml,注意该background必须为xml样式的图片:
这里我们只要关心state_checked状态就可以了。所以很简单的配置。
接下来就是布局文件里面引用这张图片了:
注意将android:button="@null"全部设为null,并且将android:background="@drawable/radio"设为刚才新建的图片。这样就完成了。
一句代码都不用写!
看看竖下来的效果:
傍边有图标的怎么办?
也很简单啦,只要在每个RadioButton上加android:drawableLeft="@drawable/tubiao_0"就可以了。
另外要设置图标与文字的距离怎么办?
有一个方法setCompoundDrawablePadding(pad)可以设置图标与文字的距离,对应的属性为android:drawablePadding。
有了这招完全可以实现类似的n选1效果,看下面:
应用:
http://www.iteye.com/topic/1116261#2256664
CircleCheckBox
https://github.com/CoXier/CheckBox
SwitchButton
https://github.com/kyleduo/SwitchButton
上面这种3选1的效果如何做呢?用代码写?
其实有更简单的办法,忘了RadioButton有什么特性了吗?
我就用RadioButton实现了如上效果,其实很简单的。
首先定义一张background,命名为radio.xml,注意该background必须为xml样式的图片:
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_checked="false" android:drawable="@drawable/tabswitcher_long" /> <item android:state_checked="true" android:drawable="@drawable/tabswitcher_short" /> </selector>
这里我们只要关心state_checked状态就可以了。所以很简单的配置。
接下来就是布局文件里面引用这张图片了:
<RadioGroup android:gravity="center" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" > <RadioButton android:id="@+id/btn_0" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="最新信息" android:textSize="17.0sp" android:textColor="@android:color/black" android:gravity="center" android:layout_weight="1" android:checked="true" android:button="@null" android:background="@drawable/radio" /> <RadioButton android:id="@+id/btn_1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="在线专家" android:textSize="17.0sp" android:textColor="@android:color/black" android:gravity="center" android:layout_weight="1" android:button="@null" android:background="@drawable/radio" /> <RadioButton android:id="@+id/btn_2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="预约服务" android:textSize="17.0sp" android:textColor="@android:color/black" android:gravity="center" android:layout_weight="1" android:button="@null" android:background="@drawable/radio" /> </RadioGroup>
注意将android:button="@null"全部设为null,并且将android:background="@drawable/radio"设为刚才新建的图片。这样就完成了。
一句代码都不用写!
看看竖下来的效果:
傍边有图标的怎么办?
也很简单啦,只要在每个RadioButton上加android:drawableLeft="@drawable/tubiao_0"就可以了。
另外要设置图标与文字的距离怎么办?
有一个方法setCompoundDrawablePadding(pad)可以设置图标与文字的距离,对应的属性为android:drawablePadding。
有了这招完全可以实现类似的n选1效果,看下面:
应用:
http://www.iteye.com/topic/1116261#2256664
CircleCheckBox
https://github.com/CoXier/CheckBox
SwitchButton
https://github.com/kyleduo/SwitchButton
评论
4 楼
464378820
2014-01-07
LZ你好,rb的图标,怎么让他自适应呢?
3 楼
难得糊涂CN2010
2013-02-06
radiobutton与radiobutton之间加上
<View android:layout_height="xxx dp" android:layout_width="xxx dp"></View>
<View android:layout_height="xxx dp" android:layout_width="xxx dp"></View>
2 楼
zourongbo007
2011-09-27
楼主你好,如果要设置radiobutton与radiobutton之间的间距(margin)呢,求思路?
另:已经在试过了android:layout_margin,不起作用。急切希望楼主给点提示。。。
另:已经在试过了android:layout_margin,不起作用。急切希望楼主给点提示。。。
1 楼
yangjiantong
2011-08-12
嗯,这个可以有!
发表评论
-
ViewPager引导页根据滑动渐变背景色
2017-03-31 09:38 28111、主要依赖: compile'com.android.su ... -
Android 新推出基于物理的动画库SpringAnimation,完全诠释什么叫做弹簧效果
2017-03-30 10:38 2566Android 最近推出一个新的基于物理学的动画支持库,命名为 ... -
一个比较强大的提供各种形状的ImageView
2016-12-26 09:54 2928github上比较老的项目了,但是还是比较好用的。 各种形状总 ... -
PhotoView点击放大图片效果
2016-12-21 10:13 6046使用的PhotoView是这个版本的,比较小巧,很好用,比gi ... -
仿微信页面切换图标颜色渐变效果
2015-11-23 14:54 4414主要是提供一种思路,一般来书,类似效果无非就是在Canvas, ... -
把任意Drawable转换成基于progress填充的drawable
2015-11-11 16:29 2744把任意Drawable转换成基于progress填充的draw ... -
一个用来设置警示View 的呼吸式背景颜色的工具类BreathingViewHelper
2015-10-10 14:03 3033一个简单的小工具类,用来设置警示 View 的呼吸式背景颜色 ... -
单手操作图片控件 镜像、置顶、缩放、移动:StickerView
2015-10-08 11:21 3160单手操作图片控件 镜像、置顶、缩放、移动 impo ... -
图片浏览zoom效果
2015-10-08 11:05 1789不仅实现了Lollipop中打开新的activity 的zoo ... -
Android App状态栏变色:ColorfulStatusBar
2015-09-24 12:38 9906适用于版本大于等于19以上。 import android ... -
PathView实现炫酷SVG动画
2015-08-25 09:23 4399解析SVG,需要将一个androidsvg.jar包含进lib ... -
LinearLayout增加divider分割线
2015-08-13 14:58 11044在android3.0及后面的版本在LinearLayout里 ... -
Android换肤白天/夜间模式的框架
2015-07-29 15:36 2927Android换肤/夜间模式的Android框架,配合them ... -
使用ActivityOptions做Activity切换动画
2015-04-10 11:02 6570不知道大家有没有注意到startActivity(Intent ... -
一个不错的ArcMenu
2015-01-23 10:34 3901ArcMenu这种效果现在很多人都实现了 而且代码质量也 ... -
使用ScheduledExecutorService延时关闭一个全屏的对话框
2014-12-29 16:38 4367自定义style,设置全屏属性 <resources ... -
让View只显示下边框
2014-10-23 17:13 3958下面的代码是实现一个带边框的xml,很常见 <?xm ... -
让一张图片从模糊慢慢变清晰动画过程
2014-01-27 16:38 9244import java.io.IOExcepti ... -
ListView,GridView之LayoutAnimation特殊动画的实现
2013-05-24 11:23 34360LayoutAnimation干嘛用的?不知道的话网上搜一下。 ... -
食神摇摇中图片的晃动效果
2013-04-27 11:45 5448可以是这样子实现滴: btn_shake=(Image ...
相关推荐
android 自定义RadioButton的样式android 自定义RadioButton的样式
仿美团支付自定义radiobutton。样式可以自己修改。 仿美团支付自定义radiobutton。样式可以自己修改。 仿美团支付自定义radiobutton。样式可以自己修改。
自定义android RadioButton样式,代码说明地址:http://blog.csdn.net/jason_996/article/details/62889374
Android自定义RadioButton和CheckBox样式,重写RadioButton的onDraw()方法,实现颜色选择器效果。
WPF 实现RadioButton样式两种方式:1资源样式 2代码调用资源样式 ,vs2010
android 自定义 单选按钮 radioButton
详细介绍了radiobutton的使用、自定义样式和需要注意问题,详细介绍请看https://blog.csdn.net/zyw0101/article/details/84138441
NULL 博文链接:https://gundumw100.iteye.com/blog/1025176
好看的自定义menu 可以点击不同部分进行切换
最近抽了点时间,针对android一些控件的样式做了完整自定义,主要包括Spinner的样式完全自定义、RadioButton[CheckBox样式雷同]样式完全自定义、Rating样式自定义,代码已经经过测试,有需要的可以下载
开发语言C#,开发环境.net,控制控件RadioButton进行美化。
最近写项目有个需求是单选框必须改成设计要的样子,然后再网上找了好久,自己调试了一下,就好了
WPF中自定义控件样式,对RadioButton的style,ControlTemplate和Trigger进行了改写
android 自定义radiobutton图片样式
本文实例讲述了Android编程实现自定义PopupMenu样式。分享给大家供大家参考,具体如下: PopupMenu是Android中一个十分轻量级的组件。与PopupWindow相比,PopupMenu的可自定义的能力较小,但使用更加方便。 先上效果...
自定义一个RadioButton,增加了设置小圆框的多种颜色外观,可以拖放到工具箱里使用
Android 自定义RadioGroup布局,修改源码自定义控件。RadioGroup组里面可以包含不同的布局,布局里面RadioButton。用了递归查找RadioButton。欢迎下载示例代码。
动态生成radioButton, 可以设置可用或者不可用 可以自定义radioButton的样式,达到setButton为null的效果 MainActivity3 的radioGroup可以支持多行
通过自定义RadioGroup,RadioButton的样式,实现最简易的仿IOS分段选择器