<@U3ZLHBTLG>, if I want to add some `View` into `V...
# splitties
i
@louiscad, if I want to add some
View
into
ViewGroup
dynamically, after it's creation, is there any way to do that shorter / with Splitties DSL?
Copy code
root.addView(childView, LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT))
All samples I've seen follow one (most common) workflow of static UI. But I need to add some views dynamically.
l
@ispbox Just use
apply
for the target
ViewGroup
, You'll then be able to work it out as when first instantiation the view hierarchy.
i
I'll just leave this sample here. Perfect solution, but not so obvious, needs some Kotlin knowledge 🙂
Copy code
root.apply {
            add(scrollView, lParams {
                width = matchParent
                height = matchParent
            })
        }