android: if scroller's child is most width,then its width should be equal to scroller's width

This commit is contained in:
pengfei.zhou 2021-10-15 10:56:52 +08:00 committed by osborn
parent ea79ea953a
commit 0dadbd473e

View File

@ -543,15 +543,15 @@ public class HVScrollView extends FrameLayout implements NestedScrollingParent,
int childWidthMeasureSpec; int childWidthMeasureSpec;
int childHeightMeasureSpec; int childHeightMeasureSpec;
final FrameLayout.LayoutParams lp = (LayoutParams) child.getLayoutParams(); final FrameLayout.LayoutParams lp = (LayoutParams) child.getLayoutParams();
if (child.getMeasuredWidth() < width && lp.width == ViewGroup.LayoutParams.MATCH_PARENT) { if (lp.width == ViewGroup.LayoutParams.MATCH_PARENT) {
childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY); childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY);
} else { } else {
widthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); widthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
childWidthMeasureSpec = getChildMeasureSpec(widthMeasureSpec, childWidthMeasureSpec = getChildMeasureSpec(widthMeasureSpec,
getPaddingLeft() + getPaddingRight(), lp.width); getPaddingLeft() + getPaddingRight(), lp.width);
} }
if (child.getMeasuredHeight() < height && lp.height == ViewGroup.LayoutParams.MATCH_PARENT) { if (lp.height == ViewGroup.LayoutParams.MATCH_PARENT) {
childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY); childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
} else { } else {
heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);