3

I want my Anko layout to have a margin of 100dp on the top, so that the background of the app that gets defined in my theme file gets shown on the top.

I tried:

        verticalLayout {
            background = resources.getDrawable(R.color.white)

            textView("Headline")
            textView("App text...")

        }.lparams(topMargin = 100)

Unfortunately, the lparams gets marked red and when I however over it I get the error unresolved reference: lparams. How do I get my top margins?

Christian
  • 25,249
  • 40
  • 134
  • 225

1 Answers1

1

Try to add a LinearLayout inside of it as follows

verticalLayout {
    linearLayout {
        background = resources.getDrawable(R.color.white)

            textView("Headline")
            textView("App text...")
    }.lparams(width = matchParent, height = matchParent) {
      topMargin = dip(100)
    }
}

Also you can add a lparams inside of the verticalLayout as follows :

verticalLayout {
    ...
    lparams { ... }
}
Skizo-ozᴉʞS ツ
  • 19,464
  • 18
  • 81
  • 148