anroid 中 shape 的使用方法
1:在res新建一个名为drawable的文件夹用于存放图片的资源文件。显然我们的shape形状文件也属于图片资源。
2:shape的属性:
xmlns:android xml文件的命名空间
android:shape 形状的种类,"rectangle" 默认矩形,"oval" 椭圆,"line" 线,
"ring" 环状 有下列特性属 性:android:innerRadius,android:innerRadiusRatio,android:innerRadiusRatio,android:thicknessRatio,android:useLevel
3:shape中可用的元素标签
corners: 圆角的效果
android:radius 为圆角的弧度,值越大角越圆润。
android:topRightRadius 右上角
android:bottomLeftRadius 右下角
android:topLeftRadius 左上角
android:bottomRightRadius 左下角
gradient:渐变的效果
android:startColor 起始颜色
android:centerColor 中间颜色
android:endColor 结束颜色
android:useLevel 若使用了 LevelListDrawable 则为"true" 否则为"false"。
android:type 渐变的模式,有三种可供选择。linear 线性渐变,radial 径向渐变,sweep 曲线渐变
android:angle 渐变的角度
android:centerX 用于线性渐变
android:centerY 同上
android:graditentRadius 用于径向渐变需要指定的半径
padding:间隔的距离,android:left,android:right,android:top,android:button属性在xml文件中常用。
size:形状的大小,android:width,android:height 就不多说了。
solid:填充的颜色,android:color
stroke: 描边的效果
android:width 描边的宽度
android:color 描边的颜色
android:dashWidth 虚线的宽度效果
android:dashGap 虚线之间的距离
4:个人的少量代码
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" > <stroke android:width="4dp" android:color="@color/unknow" /> <padding android:left="2dp" android:top="2dp" android:right="2dp" android:bottom="2dp" /> <corners android:radius="4dp"/> </shape>
之上为个人学习之用,若要详细资料,上android官方文档。xml文件下相关功能连接:http://developer.android.com/guide/topics/resources/drawable-resource.html
如果你喜欢android开发,可以加android开发者1 群:219228300 我们一起探讨问题,互相交流。
posted on 2012-04-16 11:43 null_pointer 阅读(605) 评论(0) 编辑 收藏 举报