Android shape的使用
来源:互联网 发布:单片机矩阵按键电路图 编辑:程序博客网 时间:2024/06/06 04:10
shape作为背景xml的根元素还是很有用处的,特别是在刚入门的时候
格式:
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" ><--shape作为根元素,写在最外面一层--></shape>
里面的内容可以是:
- 圆角,直接设置radius表示四个角同样的弧度,如果需要不同的弧度可以分别设置(下例中分别表示左上角、右上角、左下角和右下角)
同时设置五个属性,则Radius属性无效
<!-- 圆角 --> <corners android:radius="9dp" <!-- 每一个角的圆角半径 --> android:topLeftRadius="2dp" android:topRightRadius="2dp" android:bottomLeftRadius="2dp" android:bottomRightRadius="2dp"/> <!-- 设置圆角半径 -->
2.颜色填充
<!-- 填充 --> <solid android:color="@android:color/white"/><!-- 填充的颜色 -->
3.颜色渐变
当设置solid颜色填充以后,再设置颜色渐变是没有效果的。
- 角度angle=0时,渐变色是从左向右。然后逆时针方向转,当angle=90时为从下往上。仅在type=”linear”有效,不然会报错。
- linear 线性渐变,这是默认设置radial 放射性渐变,以开始色为中心。 sweep 扫描线式的渐变。
<!-- 渐变 --> <gradient android:startColor="@android:color/white" android:centerColor="@android:color/black" android:endColor="@android:color/black" android:useLevel="true" android:angle="45" android:type="radial" android:centerX="0" android:centerY="0" android:gradientRadius="90"/>
4.间隔/内边距
<!-- 间隔 --> <padding android:left="2dp" android:top="2dp" android:right="2dp" android:bottom="2dp"/><!-- 各方向的间隔 -->
5.描边
dashWidth和dashGap属性,只要其中一个设置为0dp,则边框为实现边框
<!-- 描边 --> <stroke android:width="2dp" android:color="@android:color/black" android:dashWidth="1dp" android:dashGap="2dp"/>
6.大小
<!-- 大小 --> <size android:width="50dp" android:height="50dp"/><!-- 宽度和高度 -->
0 0
- android:shape的使用
- android:shape的使用
- android:shape的使用
- android:shape的使用
- android:shape的使用
- android:shape的使用
- android:shape的使用
- android:shape的使用
- android:shape的使用
- android:shape的使用
- android shape的使用
- android:shape的使用
- android:shape的使用
- android:shape的使用
- android:shape的使用
- android:shape的使用
- android:shape的使用
- android:shape的使用
- [从头读历史] 第298节 时间简史 关于黑洞的那些事
- 补丁中心界面
- org.apache.hadoop.hbase.mapreduce.RowCounter源码
- Spring对JDBC的支持
- [暑假集训] jzoj 2016.7.9 noip模拟赛C 总结
- Android shape的使用
- iOS开发学习之利用系统远程UITableView 自定义滑动删除按钮、增加自定义滑动按钮方法
- 复制构造函数(拷贝构造函数)
- 浅谈变换(证明)→反演→莫比乌斯反演→线筛运用
- 修改oracle数据库的字符集
- 暑期第一弹<搜索> B - Dungeon Master(三维BFS,6个状态)
- Unity3d对于AnimationCurve的相关研究
- JavaEE 三层架构的浅谈
- Handlebars 和 angularjs 之间的区别