January 2018
Intermediate to advanced
434 pages
14h 1m
English
lparams is also an Anko extension function that is added to views, and we can define layout parameters as properties. If you omit width and/or height while using lparams(), their values automatically default to wrapContent, just like in XML. The parameters passed are named arguments. Some of the properties are horizontalMargin, verticalMargin, and margin. For different layouts, we have different layout parameters, just as in XML. For example, for relative layout, we have alignParentBottom(), alignParentTop(), alignParentStart(),leftOf(viewIdOfReferenceView),topOf(viewIdOfReferenceView) and so on.
Check out the following example, which has the relative layout as root layout:
class MainActivityUI : AnkoComponent<MainActivity> ...Read now
Unlock full access