anko
anko copied to clipboard
Create a custom View like a loading button and use it in other layouts
i want to create a customview like a loading button, something like this
val buttonLoading = verticalLayout{
textView {
}
}
and use this in other components.. can i do this with DSL and anko ?
If you have created custom view, you can do it like this
inline fun ViewManager.loadingButton(init: (LoadingButton).() -> Unit): LoadingButton {
return ankoView({ ctx -> LoadingButton(ctx) }, theme = 0) {
init()
}
}
or custom view from anko
fun ViewManager.customView(init: ConstraintLayout.() -> Unit): ConstraintLayout {
return constraintLayout {
init()
// custom view here
}
}