Android减少开发过程中Drawable xml文件的数量

支持的控件


XButton, XConstraintLayout, XEditText, XFrameLayout, XImageView, XLinearLayout, XRelativeLayout, XTextView, XCheckBox, XView, XRadioButton

上面的所有的控件都支持下面表格中的属性,表格中仅以XButtonCustom举例。

支持属性名称


| 属性名称 | 示例 |

| — | — |

| XButtonCustom_corner | 圆角度数 |

| XButtonCustom_corner_type | 圆角类型,默认 all。left_top,left_bottom,right_top,right_bottom |

| XButtonCustom_solid_color | 背景填充颜色,当没有设置渐变填充时生效 |

| XButtonCustom_shadow_color | 外阴影色值 |

| XButtonCustom_shadow_radius | 外阴影半径 |

| XButtonCustom_shadow_dx | 外阴影x方向偏移 |

| XButtonCustom_shadow_dy | 外阴影y方向偏移 |

| XButtonCustom_solid_gradient | 渐变类型,linear, radial, sweep |

| XButtonCustom_gradient_start_color | 渐变起始颜色 |

| XButtonCustom_gradient_center_color | 渐变中间颜色 |

| XButtonCustom_gradient_end_color | 渐变结束颜色 |

| XButtonCustom_gradient_orientation | 渐变的方向 |

| XButtonCustom_gradient_radius | 渐变角度 |

| XButtonCustom_stroke_color | 描边颜色 |

| XButtonCustom_stroke_border | 描边宽度 |

| XButtonCustom_blur_type | 模糊类型,默认为normal。outer,solid,inner |

| XButtonCustom_blur_radius | 模糊半径 |

| XButtonCustom_blur_color | 模糊颜色 |

| XButtonCustom_state | selector类型,默认none。pressed, selected, checked。选定上述状态时,触发state前缀的属性 |

| XButtonCustom_stated_corner | state触发的圆角 |

| XButtonCustom_corner_type | state触发时的圆角类型,默认 all。left_top,left_bottom,right_top,right_bottom |

| XButtonCustom_stated_solid_color | state出发时背景填充颜色,当没有设置渐变填充时生效 |

| XButtonCustom_stated_shadow_color | 外阴影色值 |

| XButtonCustom_stated_shadow_radius | 外阴影半径 |

| XButtonCustom_stated_shadow_dx | 外阴影x方向偏移 |

| XButtonCustom_stated_shadow_dy | 外阴影y方向偏移 |

| XButtonCustom_stated_blur_type | 模糊类型,默认为normal。outer,solid,inner |

| XButtonCustom_stated_blur_radius | 模糊半径 |

| XButtonCustom_stated_blur_color | 模糊颜色 |

| XButtonCustom_stated_solid_gradient | 渐变类型,linear, radial, sweep |

| XButtonCustom_stated_gradient_start_color | 渐变起始颜色 |

| XButtonCustom_stated_gradient_center_color | 渐变中间颜色 |

| XButtonCustom_stated_gradient_end_color | 渐变结束颜色 |

| XButtonCustom_stated_gradient_orientation | 渐变的方向 |

| XButtonCustom_stated_gradient_radius | 渐变角度 |

| XButtonCustom_stated_stroke_color | 描边颜色 |

| XButtonCustom_stated_stroke_border | 描边宽度 |

| XButtonCustom_drawable | 正常情况下显示的drawable |

| XButtonCustom_stated_drawable | 在特定状态下显示的drawable, 如: selector |

上述的字段在代码中的修改方式,支持的修改的字段在IDrawableEditTransition 接口中定义

// 获取IDrawableEditTransition

XWidgetParser.getDrawableEditTransition(v)

?.beginNormalTransition

?.setCorner(10)

?.commit()

示例

在这里插入图片描述

集成
  1. 在project build.gradle 中加入

allprojects {

repositories {

maven { url ‘https://jitpack.io’ }

}

}

  1. 在要使用的module 的 build.gradle 中加入

implementation ‘com.github.shilec:XWidget:1.2.2’

  1. 添加混淆
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值