自定义drawable(shape)
来源:互联网 发布:pdf编辑mac版 编辑:程序博客网 时间:2024/05/29 15:54
自定义drawable(shape)
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>
- <solid ...>
- </solid>
- </shape>
- </item>
- <item android:state_focused="true" >
- <shape>
- <solid ...>
- </solid>
- </shape>
- </item>
- <item android:state_pressed="true" >
- <shape>
- <solid ...>
- </solid>
- </shape>
- </item>
- </selector>
文章转自:http://blog.csdn.net/hknock/article/details/6313722
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使用详解(附图)
- mybatis 批量插入
- MYSQL学习笔记-mysql分区基本操作
- iframe自适高度
- MVC Html.AntiForgeryToken() 防止CSRF攻击
- 第一次总结报告——Vibe
- 自定义drawable(shape)
- Github Page 绑定域名
- Trac的安装与配置,整合LDAP与SVN
- mybatis整合spring的 泛型DAO接口
- 一个码农6年技术成长经历的总结和收获
- Andriod APK 反编译 及 代码混编
- [转载]Altium Designer 破解,避免局域网冲突的ad9.ini
- Mysql
- Tomcat无法启动,报错 java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory