背景形状定义工具

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"
/>

图片发自App

corners: 设置圆角。

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

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

android:topLeftRadius 左上角的半径

android:topRightRadius 右上角的半径

android:bottomLeftRadius 左下角的半径

android:bottomRightRadius 右下角的半径

图片发自App

更多相关文章

  1. 关于FrameLayout布局的位置问题
  2. textview中有很多行,我只让它显示三行,最后显示...,我设置了androi
  3. 【Android】Android中shape的使用
  4. Android中的Shape和Selector的结合使用实例
  5. android:shape的使用
  6. android中控制EditText不可编辑的问题
  7. Android:EditText 多行显示及所有属性(不自动弹出软键盘)
  8. AndroidManifest.xml - 【 manifest -> application】
  9. Android(安卓)全屏

随机推荐

  1. adb 无线调试
  2. Android系列开发博客资源汇总
  3. 浣跨敤 Android(安卓)瀹炵幇鑱旂綉
  4. Android框架模式之-MVP简单使用
  5. Android(安卓)Studio常用快捷键、Android
  6. Android中LocationManager的简单使用,获
  7. Android的广播机制——Broadcast Reciver
  8. Android适配(屏幕适配、国际化适配)
  9. Android中gravity和weight參數的用法
  10. Android星星评分控件RatingBar的使用