Anko layout

Using DSL, Anko also supports creating dynamic layouts. Just to give you an idea, the following code can create a simple EditText with a button following it:

    verticalLayout {
      val name = editText()
      button("Say Hello") {
        onClick { toast("Hello, ${name.text}!") }
      }
    }

And the screen will look like the following:

Get Kotlin Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.