anko icon indicating copy to clipboard operation
anko copied to clipboard

Create a custom View like a loading button and use it in other layouts

Open valentinjahanmanesh opened this issue 6 years ago • 1 comments

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 ?

valentinjahanmanesh avatar Mar 25 '18 19:03 valentinjahanmanesh

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
    }
}

kiratheone avatar Feb 12 '19 06:02 kiratheone