After a long time now I tried out the Anko Layout ...
# anko
s
After a long time now I tried out the Anko Layout DSL again, this time with a ConstraintLayout. This particular line of code totally blew my mind when reading through the sources:
Copy code
operator fun View.invoke(init: ViewConstraintBuilder.() -> Unit) = id.invoke(init)
It's so simple, yet so incredibly smart! Making every instance of
View
invokable with a lambda allowing us to do this:
Copy code
val myToolbar = toolbar()

myToolbar {
    connect(
            START to START of PARENT_ID,
            TOP to TOP of PARENT_ID,
            END to END of PARENT_ID
    )
}