From c45c421e48da62659f217e625ca69b6a65fd0adb Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 31 Mar 2022 17:56:22 +0100 Subject: [PATCH] adding docs around the realigning of constraint layout child percentages --- .../java/im/vector/app/core/extensions/ConstraintLayout.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vector/src/main/java/im/vector/app/core/extensions/ConstraintLayout.kt b/vector/src/main/java/im/vector/app/core/extensions/ConstraintLayout.kt index 46d173b848..b88e315978 100644 --- a/vector/src/main/java/im/vector/app/core/extensions/ConstraintLayout.kt +++ b/vector/src/main/java/im/vector/app/core/extensions/ConstraintLayout.kt @@ -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() { doOnLayout { val rootHeight = (parent as View).height