summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTinja Paavoseppä <tinja.paavoseppa@qt.io>2024-03-27 11:00:56 +0200
committerTinja Paavoseppä <tinja.paavoseppa@qt.io>2024-04-04 15:46:44 +0200
commitb3685743f31daef71021d9948deaf20ce34ce57a (patch)
tree7cecf454298d39998140f6236f448c9e35b188f2
parent7eb69e0f7a0ff874db5766fc8af039231977e6f0 (diff)
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 Pick-to: 6.7 Change-Id: I08cbfa8e352d0cb2ca5b6e5aa40e891a62b82eb4 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/QtLayout.java10
1 files 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 cf7e68926e..aedc845014 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 @@ 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 @@ 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);
}
}
}