在anko / kotlin做horizontalLayout的好方法是什么?verticalLayout工作得很好--可以在上面设定方向,但感觉不对。不知道我在那里错过了什么。
发布于 2015-05-01 21:20:41
只需使用linearLayout()函数即可。
linearLayout {
button("Some button")
button("Another button")
}发布于 2017-06-17 08:40:57
是的,在默认情况下,LinearLayout是水平的,但是我倾向于非常具体,而是使用一个单独的horizontalLayout函数。
您可以简单地将horizontalLayout函数添加到项目中:
val HORIZONTAL_LAYOUT_FACTORY = { ctx: Context ->
val view = _LinearLayout(ctx)
view.orientation = LinearLayout.HORIZONTAL
view
}
inline fun ViewManager.horizontalLayout(@StyleRes theme: Int = 0, init: _LinearLayout.() -> Unit): _LinearLayout {
return ankoView(HORIZONTAL_LAYOUT_FACTORY, theme, init)
}我在Anko:https://github.com/Kotlin/anko/issues/413上打开了一个特性请求
https://stackoverflow.com/questions/29966575
复制相似问题