From 46c639d81f72d060e1af274b5dd85d889cf2db79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tinja=20Paavosepp=C3=A4?= Date: Wed, 27 Mar 2024 11:00:56 +0200 Subject: [PATCH] Android: Make QtLayout support MATCH_PARENT layout params QtLayout did not properly handle resizing child views to the parent's size when their layout params width or height were MATCH_PARENT. This was mostly visible when embedding QML to a normal Android app, as there the Android view hierarchy is responsible for setting the size, instead of Qt setting it every time the QWindow size changes. Task-number: QTBUG-123306 Change-Id: I08cbfa8e352d0cb2ca5b6e5aa40e891a62b82eb4 Reviewed-by: Assam Boudjelthia (cherry picked from commit b3685743f31daef71021d9948deaf20ce34ce57a) Reviewed-by: Qt Cherry-pick Bot --- .../jar/src/org/qtproject/qt/android/QtLayout.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/android/jar/src/org/qtproject/qt/android/QtLayout.java b/src/android/jar/src/org/qtproject/qt/android/QtLayout.java index 95173d86059..ed64e5f4832 100644 --- a/src/android/jar/src/org/qtproject/qt/android/QtLayout.java +++ b/src/android/jar/src/org/qtproject/qt/android/QtLayout.java @@ -91,7 +91,6 @@ public class QtLayout extends ViewGroup protected void onLayout(boolean changed, int l, int t, int r, int b) { int count = getChildCount(); - for (int i = 0; i < count; i++) { View child = getChildAt(i); if (child.getVisibility() != GONE) { @@ -100,10 +99,11 @@ public class QtLayout extends ViewGroup int childLeft = lp.x; int childTop = lp.y; - child.layout(childLeft, childTop, - childLeft + child.getMeasuredWidth(), - childTop + child.getMeasuredHeight()); - + int childRight = (lp.width == ViewGroup.LayoutParams.MATCH_PARENT) ? + r - l : childLeft + child.getMeasuredWidth(); + int childBottom = (lp.height == ViewGroup.LayoutParams.MATCH_PARENT) ? + b - t : childTop + child.getMeasuredHeight(); + child.layout(childLeft, childTop, childRight, childBottom); } } }