0

android-drawable-dsl 用 DSL 替代 XML 写 drawables

will 发布于1年前 阅读数 2399

https://github.com/infotech-group/android-drawable-dsl

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <solid android:color="#199fff" />
    <stroke
        android:width="2dp"
        android:color="#444444" />
</shape>

DSL 写法

shapeDrawable {
  shape = GradientDrawable.OVAL

  solidColor = Color.parseColor("#199fff")

  stroke {
    width = dip(2)
    color = Color.parseColor("#444444")
  }
}
举报
回复