0

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

will created at6 years ago view count: 2905

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")
  }
}
report
回复

Recent search keywords