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 <assam.boudjelthia@qt.io>
(cherry picked from commit b3685743f31daef71021d9948deaf20ce34ce57a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tinja Paavoseppä 2024-03-27 11:00:56 +02:00 committed by Qt Cherry-pick Bot
parent 16b93bb04f
commit 46c639d81f

View File

@ -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);
}
}
}