背景形状定义工具

shape可以自定义形状

属性

android:shape

rectangle矩形

oval椭圆

line线形

ring环型

solid: 设置形状填充的颜色

属性android:color

padding: 设置内容与形状边界的内间距

可分别设置左右上下的距离

android:left 左内间距

android:right 右内间距

android:top 上内间距

android:bottom 下内间距

stroke: 设置描边,可描成实线或虚线。

android:color 描边的颜色

android:width 描边的宽度

android:dashWidth 设置虚线时的横线长度

android:dashGap 设置虚线时的横线之间的距离

size

width,height

通常shape都是作为background的,所以这个size通常不会有效,而是控件的宽高为准

实例

linearlayout添加分隔线


gradient: 设置形状的渐变颜色,可以是线性渐变、辐射渐变、扫描性渐变

android:type 渐变的类型

linear 线性渐变,默认的渐变类型

radial 放射渐变,设置该项时,android:gradientRadius也必须设置

sweep 扫描性渐变

android:startColor 渐变开始的颜色

android:endColor 渐变结束的颜色

android:centerColor 渐变中间的颜色

android:angle 渐变的角度,线性渐变时才有效,必须是45的倍数,0表示从左到右,90表示从下到上

android:centerX 渐变中心的相对X坐标,放射渐变时才有效,在0.0到1.0之间,默认为0.5,表示在正中间

android:centerY 渐变中心的相对X坐标,放射渐变时才有效,在0.0到1.0之间,默认为0.5,表示在正中间

android:gradientRadius 渐变的半径,只有渐变类型为radial时才使用

android:startColor="#fff"
android:centerColor="#f1a9a9"
android:endColor="#ec5b5b"
android:type="linear"
/>

安卓样式之shape(形状)_第1张图片图片发自App

corners: 设置圆角。

只适用于rectangle类型,可分别设置四个角不同半径的圆角

android:radius 圆角半径,会被下面每个特定的圆角属性重写

android:topLeftRadius 左上角的半径

android:topRightRadius 右上角的半径

android:bottomLeftRadius 左下角的半径

android:bottomRightRadius 右下角的半径

安卓样式之shape(形状)_第2张图片图片发自App

更多相关文章

  1. Android textView字间距自定义LetterSpacingTextView
  2. Android如何设置TextView的行间距、行高
  3. Android设置TextView的行间距、行高。
  4. Android TextView行间距解析
  5. Android设置字间距和行间距
  6. 形状图形(shape)

随机推荐

  1. android 全面屏适配方案
  2. android 中的实现加水印
  3. 编写第一个Android程序
  4. Matisse Android(安卓)图片选择器
  5. Ubuntu 14.04 连接Android 手机(三星note
  6. Android添加半透明操作提示的方法
  7. Android学习--使用url访问网络资源
  8. android 9.0 获取U盘路径
  9. android之ViewFlipper滑屏切换效果
  10. 获取视频缩略图