Android自定义Button背景色,弧度
2016-05-09 15:51
501 查看
Android自定义Button背景色,弧度
作为selector放在drawable中android:state_pressed=”true” 点击
android:state_focused=”true” 聚焦
自定义的Button的xml文件(res/drawable/button_selector.xml)
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- pressed --> <item android:state_pressed="true" > <shape android:shape="rectangle"> <gradient android:startColor="#ff8c00" android:endColor="#ff8c00" android:angle="270" /> <corners android:radius="4dp" /> </shape> </item> <!-- focus --> <item android:state_focused="true" > <shape> <gradient android:startColor="#ffc2b7" android:endColor="#ffc2b7" android:angle="270" /> <corners android:radius="4dp" /> </shape> </item> <!-- default --> <item> <shape> <gradient android:startColor="#d0d0d0" android:endColor="#d0d0d0" android:angle="0" /> <corners android:radius="4dp" /> </shape> </item> </selector>
引用
<RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingRight="10dip" android:paddingTop="3dip"> <TextView android:id="@+id/time" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:textColor="@color/light_grey" /> <Button android:id="@+id/agree" android:layout_width="wrap_content" android:layout_height="23dip" android:layout_toLeftOf="@+id/publish" android:drawableLeft="@drawable/agree_view" android:layout_marginRight="10dip" android:gravity="center" android:textSize="@dimen/text_size_common" android:textColor="@color/light_grey" android:background="@drawable/button_selectort" /> <Button android:id="@+id/publish" android:layout_width="wrap_content" android:layout_height="23dip" android:layout_alignParentRight="true" android:drawableLeft="@drawable/reply_view" android:gravity="center" android:textSize="@dimen/text_size_common" android:textColor="@color/light_grey" android:background="@drawable/button_selector" /> </RelativeLayout>
相关文章推荐
- Android 高清加载巨图方案 拒绝压缩图片
- android图片压缩终极解决方案
- Snmp学习总结(二)——SNMP4J介绍
- android 无线调试
- Android限定符使用【初级】
- 对 Android 开发者有益的 40 条优化建议
- AndroidStudio 分享项目到 git
- AndroidManifest.xml官方介绍
- Android游戏编程笔记(二)
- 15 个 Android 通用流行框架大全
- Android开发之多级下拉列表菜单实现(仿美团,淘宝等)
- Android截屏
- Android Studio --基础介绍之Gradle详解
- 查找并修复Android中的内存泄露—OutOfMemoryError
- (4.1.11.4)Android RecyclerView 使用完全解析 体验艺术般的控件
- android分享 ------ 友盟分享(续)
- 查找并修复Android中的内存泄露—OutOfMemoryError
- Android 热补丁动态修复框架小结
- Android Gradle使用详解
- 相关编译到Android细节总结 编译加入curl关联lib与头文件 && 解决pthread的cancel函数NDK不支持,找不到sockaddr_i