做一个好方法是什么 horizontalLayout
在anko / kotlin? verticalLayout
工作正常 - 可以设置方向,但感觉不对。不知道我在那里失踪了什么。
做一个好方法是什么 horizontalLayout
在anko / kotlin? verticalLayout
工作正常 - 可以设置方向,但感觉不对。不知道我在那里失踪了什么。
只需使用一个 linearLayout()
功能而不是。
linearLayout {
button("Some button")
button("Another button")
}
只需使用一个 linearLayout()
功能而不是。
linearLayout {
button("Some button")
button("Another button")
}
是啊, 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