ispbox
08/08/2019, 9:35 AMreturn scrollView {
verticalLayout {
}.lparams {
margin = dip(buttonMargin) // Margin for all sides, except bottom (it doesn't work in ScrollView).
}
bottomPadding = dip(2 * buttonMargin) // Special padding for bottom of ScrollView.
}
I tried something like:
private val scrollView = view(::ScrollView) {
add(content, lParams {
margin = dip(buttonMargin) // Margin for all sides, except bottom (it doesn't work in ScrollView).
width = matchParent
height = matchParent
bottomPadding = dip(buttonMargin) // Special padding for bottom of ScrollView.
})
}
override val root = verticalLayout {
background = resources.getDrawable(android.R.color.white, null)
add(scrollView, lParams {
margin = dip(buttonMargin) // Margin for all sides, except bottom (it doesn't work in ScrollView).
width = matchParent
height = matchParent
bottomPadding = dip(buttonMargin) // Special padding for bottom of ScrollView.
})
}
But no margins/padding is applied at all. What's wrong?louiscad
08/08/2019, 10:12 AMLinearLayout
inside a ScrollView
in the Anko snippet, but the other way around for the Splitties snippet.
For the Splitties version, you should use the wrapInScrollView()
extension function instead of view(::ScrollView)
, it's simpler and harder to misuse. After that, make sure you're setting the margin on the right layout params, and the padding on the right view (beware of receiver clash if any, the closest one will be picked).ispbox
08/08/2019, 10:51 AMprivate val scrollView = view(::ScrollView) {
background = resources.getDrawable(android.R.color.holo_red_dark, null)
add(content, lParams {
margin = dip(10)
width = matchParent
height = matchParent
})
}
override val root = verticalLayout {
background = resources.getDrawable(android.R.color.white, null)
add(scrollView, lParams {
width = matchParent
height = matchParent
bottomPadding = dip(10)
})
}
wrapInScrollView()
correctly.Ui
interface is much better 🙂louiscad
08/08/2019, 12:36 PMwrapInScrollView
without having to bring your own version to support non default layout params, you could probably ditch usage of margin and use padding only for the content of the ScrollView.
I'm interested to know how it works for you with Conductor, please let me know then!
And thanks for the recognition, I appreciate it.ispbox
08/08/2019, 4:29 PMcould probably ditch usage of margin and use padding only for the content of the ScrollViewUnfortunately that's not the case. It is Android bug with ScrollView - it cuts its content from bottom. And in case of padding I get scrollbar in not appropriate place 🙂 I'll keep you informed about my experience with Conductor + Splitties DSL.
private val scrollView = view(::ScrollView) {
add(content, lParams {
width = matchParent
height = matchParent
horizontalMargin = dip(buttonMargin) // Margin for left and right.
verticalPadding = dip(buttonMargin) // Padding for top and bottom. Works good with clipToPadding = false
clipToPadding = false
})
}