自定义drawable(shape)
来源:互联网 发布:java权限管理的实现 编辑:程序博客网 时间:2024/06/06 02:33
原文地址:点击打开链接
android中可以通过shape对drawable进行自定义。
- <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
- <solid android:color="#f033ff22"/>
- <stroke android:width="2dp" android:color="#ff1111" android:dashWidth="2dp"
- android:dashGap="0dp" />
- <padding android:left="10dp" android:top="10dp"
- android:right="10dp" android:bottom="10dp" />
- <corners android:radius="6dp" />
- </shape>
solid中定义的颜色值需要包含alpha值,
stroke可以定义边框的颜色,width为边框的宽度,dashWidth为画笔的宽度,dashGap为画笔的间距
(dashGap为0,则边框为实心的边线)
corners定义四角圆弧的半径。
TIP:
对于使用selector定义不同的状态也可以使用shape替代drawable的属性。
- <?xml version="1.0" encoding="utf-8"?>
- <selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_focused="false"
- android:drawable="@drawable/gallery_selected_unfocused" />
- <item android:state_focused="true"
- android:drawable="@drawable/gallery_selected_focused" />
- <item android:state_pressed="true"
- android:drawable="@drawable/gallery_unselected_focused" />
- <item android:state_selected="true"
- android:drawable="@drawable/gallery_unselected_focused" />
- </selector>
- <?xml version="1.0" encoding="utf-8"?>
- <selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_focused="false" >
- <shape>
0 0
- 自定义drawable(shape)
- 自定义drawable(shape)
- 自定义drawable(shape)
- 自定义drawable(shape)
- 自定义drawable(selector、shape)
- 自定义drawable android:shape
- shape自定义drawable
- android 自定义Drawable Shape 的应用
- Android中用Shape Drawable实现自定义界面
- 用到的drawable selector和shape自定义
- drawable自定义图形资源之shape属性
- Drawable Shape
- Shape Drawable
- Shape Drawable
- Drawable之Shape drawable
- Android学习之路------自定义drawable之shape属性
- android自定义drawable之shape、selector和layer-list详解
- Android Drawable - Shape Drawable使用详解(附图)
- 从一家电子商务网站学到的经验教训
- 教你实现同一IP多域名对应多个站点_908
- hibernate.properties与hibernate.cfg.xml 区别
- 指针
- tomcat性能调优
- 自定义drawable(shape)
- Ubuntu上使用ADB工具
- 【硅谷年会】吴军谈机器智能:创新和创业的下一个浪潮
- Effective JavaScript Item 55 接受配置对象作为函数参数
- Nginx 基本配置知识
- 修美乐:艾伯维2014加速?修美乐领前
- 一步一步学zedboard之十三利用u-boot引导内核
- Windows中DLL文件的意义及其作用
- 近100个C语言基础算法案例(初级篇)