shape 常用属性

android:shape="rectangle" 矩形,默认值
android:shape="oval" 椭圆,此时corners (圆角节点)失效
android:shape="line" 直线,必须设置stroke(描边)节点
android:shape="ring" 圆环

下面定义了6种图形

  • corners (圆角)

    android:radius="20dp" 直接定义4个圆角
    android:bottomLeftRadius="20dp" 左下角
    android:bottomRightRadius="20dp" 右下角
    android:topLeftRadius="20dp" 左上角
    android:topRightRadius="20dp" 右上角
<?xml version="1.0" encoding="utf-8"?>              
image.png
  • gradien(渐变)

android:angle ( 起始角度 0 -9点方向 90- 6点方向 180 -3点方向 270 12点方向)
android:type (linear 线性渐变 默认值 , radial 放射渐变 起始颜色是圆心, sweep 滚动渐变)
android:centerY="0.4" 圆心y坐标

<?xml version="1.0" encoding="utf-8"?>    
image.png
  • padding (定义内容离边界的距离)

  • solid(填充颜色,背景色)

 
  • size(尺寸)

无节点表示宽高自适应

  • stroke(描边)

android:dashGap="@dimen/len_4" 每段虚线之间的间隔
android:dashWidth="@dimen/len_4" 每段虚线之间的宽度
上面2个同时存在才为虚线
android:width="@dimen/len_4" 描边厚度

<?xml version="1.0" encoding="utf-8"?>            
image.png
<?xml version="1.0" encoding="utf-8"?>            

v21 涟漪效果

<?xml version="1.0" encoding="utf-8"?>                                                    
v21 以上 v21 以下                                    

进阶

点击背景 实现变色

<?xml version="1.0" encoding="utf-8"?>                                                                                                   

更多相关文章

  1. Android帧布局-实现渐变效果
  2. Drawable
  3. android中自定义shape
  4. Android(安卓)背景渐变 渐变背景 shape
  5. Android中自定义shape
  6. Android(安卓)Drawable Resources系列10:
  7. android之shape
  8. Android中的Shape使用总结
  9. android shape控件的使用

随机推荐

  1. ADT-abundle-使用过程中不断出现的错误
  2. 关于Android自定义相机进行拍照(小米手机
  3. android: 不需要焦点的TextView跑马灯 Ma
  4. Android XMl写入
  5. android apk源码
  6. Android Webview与Html5交互
  7. 2015.01.16 Android错误集(1)
  8. Android 沉浸式状态栏 +DrawerLayout+Too
  9. Android HandlerThread总结
  10. android资源网址大全