RadioButton自定义样式 之一 换图片
来源:互联网 发布:网站用php与asp哪个好 编辑:程序博客网 时间:2024/06/06 01:45
radiobutton 、checkbox默认的图片太挫了,那我们自己来定义一下他的样式
1、找两张图片:选中和未选中的
2、再来张背景图片
3、定义状态
radiobutton_icon.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/btn_check_off_selected" />
<item
android:state_checked="true"
android:drawable="@drawable/btn_check_on_selected" />
</selector>
4、定义样式
<style name="RadioBtnMyIcon">
<item name="android:background">@drawable/item_bg</item>
<item name="android:button">@drawable/radiobutton_icon</item>
</style>
ok了,现在引用一下
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/RadioBtnMyIcon"
android:text="选项1"
/>
效果
select基础知识补充
<item>
android:state_pressed
Boolean。“true”表示按下状态使用(例如按钮按下);“false”
表示非按下状态使用。
android:state_focused
Boolean。“true”表示聚焦状态使用(例如使用滚动球/D-pad
聚焦Button);“false”表示非聚焦状态使用。
android:state_selected
Boolean。“true”表示选中状态使用(例如Tab 打开);“false”
表示非选中状态使用。
android:state_checkable
Boolean。“true”表示可勾选状态时使用;“false”表示非可
勾选状态使用。(只对能切换可勾选—非可勾选的构件有用。)
android:state_checked
Boolean。“true”表示勾选状态使用;“false”表示非勾选
状态使用。
android:state_enabled
Boolean。“true”表示可用状态使用(能接收触摸/点击事件);
“false”表示不可用状态使用。
android:window_focused
Boolean。“true”表示应用程序窗口有焦点时使用(应用程序
在前台);“false”表示无焦点时使用(例如Notification栏拉
下或对话框显示)。
注意:记住一点,StateList中第一个匹配当前状态的item会被使用。因此,如果第一个item没
有任何状态特性的话,那么它将每次都被使用,这也是为什么默认的值必须总是在最后
- RadioButton自定义样式 之一 换图片
- android RadioButton自定义图片样式
- RadioButton - android 自定义RadioButton样式
- 自定义RadioButton样式1
- 自定义RadioButton样式
- RadioButton自定义样式
- android 自定义RadioButton样式
- 自定义RadioButton样式2
- 自定义RadioButton样式
- 自定义RadioButton样式2
- android 自定义RadioButton样式
- Android 自定义RadioButton样式
- 如何自定义RadioButton样式
- Android自定义RadioButton样式
- android 自定义RadioButton样式
- 如何自定义RadioButton样式
- radiobutton设置自定义样式
- android 自定义RadioButton样式
- iPad征服内存优化以及因此产生的令人崩溃的崩溃问题
- vsftp指定匿名访问目录和系统用户访问目录
- android使用XmlPullParser来解析XML文件
- iPad网游输入优化
- 关于使用Mina做客户端和服务端传递对象的问题
- RadioButton自定义样式 之一 换图片
- android ndk使用iconv1.14
- 用ascii编码表示字符"
- webview与js的通信框架
- vs2010编译iconv1.14
- GBus count
- Cycle Time、Takt Time、Actual Takt Time和Lead Time
- SGU水题大集合 SGU104 SGU105 SGU107
- 归并排序求逆序数模板