I want to create a custom View which is just a wrapper of some Android Views. I looked into creating a custom ViewGroup which manages the layout of it\'s child views, but I don\
I was looking for something like this too, but the most optimal solution i found for custom views is something like this:
public inline fun ViewManager.customLayout(theme: Int = 0) = customLayout(theme) {}
public inline fun ViewManager.customLayout(theme: Int = 0, init: CustomLayout.() -> Unit) = ankoView({ CustomLayout(it) }, theme, init)
class CustomLayout(c: Context) : LinearLayout(c) {
init {
addView(textView("Some text"))
addView(textView("Other text"))
}
}
you can use ViewManager.
fun ViewManager.swipeLayout() = linearLayout {
textView {
text = "Some text"
}
textView {
text = "Another text"
}
}
class MainActivity
verticalLayout {
textView {
text = "Something that comes above the swipe"
}
swipeLayout {}
}