adding docs around the realigning of constraint layout child percentages

This commit is contained in:
Adam Brown 2022-03-31 17:56:22 +01:00
parent 468a81e1c3
commit c45c421e48

View File

@ -31,6 +31,11 @@ fun ConstraintLayout.updateConstraintSet(block: (ConstraintSet) -> Unit) {
} }
} }
/**
* Helper to recalculate all ConstraintLayout child views with percentage based height against the parent's height.
* This is helpful when using a ConstraintLayout within a ScrollView as any percentages will use the total scrolling size
* instead of the viewport/ScrollView height
*/
fun ConstraintLayout.realignPercentagesToParent() { fun ConstraintLayout.realignPercentagesToParent() {
doOnLayout { doOnLayout {
val rootHeight = (parent as View).height val rootHeight = (parent as View).height