Anko DSL Kotlin | How to use Anko DSL inside a Fragment?

Published by inkskull on

Checkout the Anko DSL Kotlin | How to use Anko DSL inside a Fragment?

After digging up anko-support-v4 source code plus some trial and errors.

override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {

    return UI {
        verticalLayout {
            linearLayout {
                avatar = imageView().lparams(width = dip(48), height = dip (48))
                name = textView().lparams(width = 0, weight = 1f)
            }

            linearLayout {
                // ...
            }
        }
    }.toView()
Categories: AndroidKotlin

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Social Media Auto Publish Powered By : XYZScripts.com