Yes, LinearLayout is horizontal by default, but I tend to be more specific and rather use a separate horizontalLayout function for this.
You can simply add the horizontalLayout function to your project:
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) }
I opened a function request in Anko: https://github.com/Kotlin/anko/issues/413
Martin vysny
source share