android shape 基本语法
android shape 基本语法
语法:(摘抄自点击打开链接)
[code]<span style="color: rgb(0, 112, 0);"><?xml version="1.0" encoding="utf-8"?> <shape </span><span style="color:#993399;">xmlns:android</span><span style="color:#007000;">="http://schemas.android.com/apk/res/android" </span><span style="color:#993399;">android:shape</span><span style="color:#007000;">=["rectangle" | "oval" | "line" | "ring"] > <corners android:radius="integer" android:topLeftRadius="integer" android:topRightRadius="integer" android:bottomLeftRadius="integer" android:bottomRightRadius="integer" /> <gradient android:angle="integer" android:centerX="integer" android:centerY="integer" android:centerColor="integer" android:endColor="color" android:gradientRadius="integer" android:startColor="color" android:type=["linear" | "radial" | "sweep"] android:useLevel=["true" | "false"] /> <padding android:left="integer" android:top="integer" android:right="integer" android:bottom="integer" /> <size android:width="integer" android:height="integer" /> <solid android:color="color" /> <stroke android:width="integer" android:color="color" android:dashWidth="integer" android:dashGap="integer" /> </shape></span>
<shape>根元素
xmlns:android
String.定义XML的命名空间,它必须是
"http://schemas.android.com/apk/res/android".
android:shape
Keyword.定义shape在形状,可选值是:
Value | Desciption |
---|---|
"rectangle" |
长方形(默认形状) |
"oval" |
椭圆形(宽高一样就是圆形) |
"line" |
线条 |
"ring" |
圆环形 |
以下属性只有当 android:shape="ring" 时才有效:
android:innerRadiusDimension.定义环形内部空白部分的半径,值必须是一个尺寸(dp)值 android:innerRadiusRatio
Float.定义环形内部空白部分的半径,如果android:innerRadiusTatio="5",那么就用环空白部分的半径就是环的宽度除以5,默认为9如果定义了android:innerRadius则此条属性无效。
android:thickness
Dimension.环的厚度。值必须是一个尺寸(dp)值
android:thicknessRatio
Float.定义环的厚度。如果android:thicknessRatio="2",那么环的厚度就是环的宽度除以2。默认为3
如果定义了android:thickness则此条属性无效
android:useLevel
Boolean."true" 使用LevelListDrawable实例,"false"则不使用
1.solid: 填充
android:color
Color.指定填充的颜色
2.gradient: 渐变
android:type
Integer.渐变类型,分别为(linear|sweep|radial)三种渐变类型(默认为linear)
android:startColor
Color.渐变开始颜色
android:centerColor
Color.渐变中间颜色
android:endColor
Color.渐变结束颜色
android:centerX
Float.对应渐变中心的X偏移位置。(0 - 1.0)
android:centerY
Float.对应渐变中心的Y偏移位置。(0 - 1.0)
android:angle
Integer.渐变角度。0度是从左到右;90度是从下到上。它必须是45的整数倍,默认为0
android:gradientRadius
Float.径向渐变的半径。只有当android:type=“radial”才有效
android:useLevel
Boolean.是否使用LeveListDrawable对象。"true" or "false"
3.stroke: 描边
android:width
Dimension.线的厚度,一个尺寸值(dp)或dimension resource
android:color
Color.线的颜色,一个颜色(#ff56ff56)或color resource,默认为透明色
android:dashGap
Dimension.虚线之间的间隔距离,0为实线
android:dashWidth
Dimension.单个虚线的宽度,0为实线
4.corners: 圆角,只有当android:shape="rectangle"才有效
android:radius
Dimension.设置所有角的弧度,一个尺寸值(dp)或dimension resource。如果设置了下面的四个属性中的一个那这个属性将失去效果。
android:topLeftRadius
Dimension.左上角的弧度,一个尺寸值(dp)或dimension resource
android:topRightRadius
Dimension.右上角的弧度,一个尺寸值(dp)或dimension resource
android:bottomLeftRadius
Dimension.左下角的弧度,一个尺寸值(dp)或dimension resource
android:bottomRightRadius
Dimension.右下角的弧度,一个尺寸值(dp)或dimension resource
5.padding: 内边距,即内容与边的距离
android:left
Dimension.左边距,一个尺寸值(dp)或dimension resource
android:top
Dimension.上边距,一个尺寸值(dp)或dimension resource
android:right
Dimension.右边距,一个尺寸值(dp)或dimension resource
android:bottom
Dimension.下边距,一个尺寸值(dp)或dimension resource
6.size: 设置shape在size
android:width
Dimension.shape的宽度,一个尺寸值(dp)或dimension resource
android:height
Dimension.shape的高度,一个尺寸值(dp)或dimension resource
Value | Desciption |
---|---|
"rectangle" |
A rectangle (长方形)that fills the containing View. This is the default shape.(这个是默认的形状) |
"oval" |
An oval (椭圆形)shape that fits the dimensions of the containing View. |
"line" |
A horizontalline that spans the width of the containing View. This shape requires the <stroke>element to define the width of the line. |
"ring" |
A ring shape. |
- 点赞 1
- 收藏
- 分享 1aa70
- 文章举报
- 为什么Android系统要比ios卡。
- Android系统框架
- cordova android打包apk报错 Error: Cannot find module 'q'报错解决
- Android 源码proguard的使用
- 学习日记android为menu添加button和事件
- 读书笔记(一)---GoogleAndroid开发入门指南(第二版)人民邮电出版社
- 开发者不得不知的Android权限说明
- Android动画-收缩菜单
- J2ME和Android的简单比较
- Android开发(一)发送短信程序
- Android Service启动执行顺序
- Android的Error:(26, 13) Failed to resolve: com.android.support:appcompat-v7:29.+报错怎么处理啊
- android studio Error(26,13)
- ARM64下的Android Native Hook工具实践
- android——listview删除的简单实现
- 转的关于android3.0的文章
- Android学习之路(转载)
- 如何利用Android studio快速的将自己的项目传到GitHub上
- Android中的“色图”(Color Drawable)资源
- Android中的Handler总结