In my android app, the below works fine to useRelativeLayout:
main_layout.addView(card1)
main_layout.addView(card2,
RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.WRAP_CONTENT).apply {
addRule(RelativeLayout.BELOW, card1.id)
})
main_layout.addView(Settings(this),
RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.WRAP_CONTENT).apply {
addRule(RelativeLayout.BELOW, card2.id)
}
)
As seen, I used the below code more than once, is there a way to simplify it, and avoid keeping rewriting it using Kotlin extensions?:
RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.WRAP_CONTENT).apply { .. }