Android开发者的Anko使用指南(三)之资源

时间:2023-03-09 03:40:31
Android开发者的Anko使用指南(三)之资源

添加依赖

dependencies {
compile "org.jetbrains.anko:anko-commons:$anko_version"

}

Color

0xff0000.opaque 不透明的红色

Dimensions

使用dipsp:dip(dipValue)或者sp(spValue)

applyRecursively()

applyRecursively()应用于lambda表达式的本身,然后递归地运用在他的子view

verticalLayout {
editText {
hint = "Name"
}
editText {
hint = "Password"
}
}.applyRecursively { view -> when(view) {
is EditText -> view.textSize = 20f
}}

以上表示,该layout中的editexttextSize都为20sp