Loading core/java/android/widget/HorizontalScrollView.java +30 −19 Original line number Original line Diff line number Diff line Loading @@ -325,16 +325,24 @@ public class HorizontalScrollView extends FrameLayout { if (getChildCount() > 0) { if (getChildCount() > 0) { final View child = getChildAt(0); final View child = getChildAt(0); int width = getMeasuredWidth(); final int widthPadding; if (child.getMeasuredWidth() < width) { final int heightPadding; final FrameLayout.LayoutParams lp = (LayoutParams) child.getLayoutParams(); final FrameLayout.LayoutParams lp = (LayoutParams) child.getLayoutParams(); final int targetSdkVersion = getContext().getApplicationInfo().targetSdkVersion; if (targetSdkVersion >= Build.VERSION_CODES.M) { widthPadding = mPaddingLeft + mPaddingRight + lp.leftMargin + lp.rightMargin; heightPadding = mPaddingTop + mPaddingBottom + lp.topMargin + lp.bottomMargin; } else { widthPadding = mPaddingLeft + mPaddingRight; heightPadding = mPaddingTop + mPaddingBottom; } int childHeightMeasureSpec = getChildMeasureSpec(heightMeasureSpec, mPaddingTop int desiredWidth = getMeasuredWidth() - widthPadding; + mPaddingBottom, lp.height); if (child.getMeasuredWidth() < desiredWidth) { width -= mPaddingLeft; final int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec( width -= mPaddingRight; desiredWidth, MeasureSpec.EXACTLY); int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY); final int childHeightMeasureSpec = getChildMeasureSpec( heightMeasureSpec, heightPadding, lp.height); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); } } } } Loading Loading @@ -1235,17 +1243,17 @@ public class HorizontalScrollView extends FrameLayout { } } @Override @Override protected void measureChild(View child, int parentWidthMeasureSpec, int parentHeightMeasureSpec) { protected void measureChild(View child, int parentWidthMeasureSpec, int parentHeightMeasureSpec) { ViewGroup.LayoutParams lp = child.getLayoutParams(); ViewGroup.LayoutParams lp = child.getLayoutParams(); int childWidthMeasureSpec; final int horizontalPadding = mPaddingLeft + mPaddingRight; int childHeightMeasureSpec; final int childWidthMeasureSpec = MeasureSpec.makeSafeMeasureSpec( Math.max(0, MeasureSpec.getSize(parentWidthMeasureSpec) - horizontalPadding), childHeightMeasureSpec = getChildMeasureSpec(parentHeightMeasureSpec, mPaddingTop MeasureSpec.UNSPECIFIED); + mPaddingBottom, lp.height); childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); final int childHeightMeasureSpec = getChildMeasureSpec(parentHeightMeasureSpec, mPaddingTop + mPaddingBottom, lp.height); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); } } Loading @@ -1257,8 +1265,11 @@ public class HorizontalScrollView extends FrameLayout { final int childHeightMeasureSpec = getChildMeasureSpec(parentHeightMeasureSpec, final int childHeightMeasureSpec = getChildMeasureSpec(parentHeightMeasureSpec, mPaddingTop + mPaddingBottom + lp.topMargin + lp.bottomMargin mPaddingTop + mPaddingBottom + lp.topMargin + lp.bottomMargin + heightUsed, lp.height); + heightUsed, lp.height); final int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec( final int usedTotal = mPaddingLeft + mPaddingRight + lp.leftMargin + lp.rightMargin + lp.leftMargin + lp.rightMargin, MeasureSpec.UNSPECIFIED); widthUsed; final int childWidthMeasureSpec = MeasureSpec.makeSafeMeasureSpec( Math.max(0, MeasureSpec.getSize(parentWidthMeasureSpec) - usedTotal), MeasureSpec.UNSPECIFIED); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); } } Loading core/java/android/widget/ScrollView.java +21 −17 Original line number Original line Diff line number Diff line Loading @@ -350,12 +350,10 @@ public class ScrollView extends FrameLayout { if (getChildCount() > 0) { if (getChildCount() > 0) { final View child = getChildAt(0); final View child = getChildAt(0); final int height = getMeasuredHeight(); if (child.getMeasuredHeight() < height) { final int widthPadding; final int widthPadding; final int heightPadding; final int heightPadding; final FrameLayout.LayoutParams lp = (LayoutParams) child.getLayoutParams(); final int targetSdkVersion = getContext().getApplicationInfo().targetSdkVersion; final int targetSdkVersion = getContext().getApplicationInfo().targetSdkVersion; final FrameLayout.LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (targetSdkVersion >= VERSION_CODES.M) { if (targetSdkVersion >= VERSION_CODES.M) { widthPadding = mPaddingLeft + mPaddingRight + lp.leftMargin + lp.rightMargin; widthPadding = mPaddingLeft + mPaddingRight + lp.leftMargin + lp.rightMargin; heightPadding = mPaddingTop + mPaddingBottom + lp.topMargin + lp.bottomMargin; heightPadding = mPaddingTop + mPaddingBottom + lp.topMargin + lp.bottomMargin; Loading @@ -364,10 +362,12 @@ public class ScrollView extends FrameLayout { heightPadding = mPaddingTop + mPaddingBottom; heightPadding = mPaddingTop + mPaddingBottom; } } final int desiredHeight = getMeasuredHeight() - heightPadding; if (child.getMeasuredHeight() < desiredHeight) { final int childWidthMeasureSpec = getChildMeasureSpec( final int childWidthMeasureSpec = getChildMeasureSpec( widthMeasureSpec, widthPadding, lp.width); widthMeasureSpec, widthPadding, lp.width); final int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec( final int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec( height - heightPadding, MeasureSpec.EXACTLY); desiredHeight, MeasureSpec.EXACTLY); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); } } } } Loading Loading @@ -1268,9 +1268,10 @@ public class ScrollView extends FrameLayout { childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, mPaddingLeft childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, mPaddingLeft + mPaddingRight, lp.width); + mPaddingRight, lp.width); final int verticalPadding = mPaddingTop + mPaddingBottom; childHeightMeasureSpec = MeasureSpec.makeSafeMeasureSpec( childHeightMeasureSpec = MeasureSpec.makeSafeMeasureSpec( MeasureSpec.getSize(parentHeightMeasureSpec), MeasureSpec.UNSPECIFIED); Math.max(0, MeasureSpec.getSize(parentHeightMeasureSpec) - verticalPadding), MeasureSpec.UNSPECIFIED); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); } } Loading @@ -1283,8 +1284,11 @@ public class ScrollView extends FrameLayout { final int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, final int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, mPaddingLeft + mPaddingRight + lp.leftMargin + lp.rightMargin mPaddingLeft + mPaddingRight + lp.leftMargin + lp.rightMargin + widthUsed, lp.width); + widthUsed, lp.width); final int usedTotal = mPaddingTop + mPaddingBottom + lp.topMargin + lp.bottomMargin + heightUsed; final int childHeightMeasureSpec = MeasureSpec.makeSafeMeasureSpec( final int childHeightMeasureSpec = MeasureSpec.makeSafeMeasureSpec( MeasureSpec.getSize(parentHeightMeasureSpec), MeasureSpec.UNSPECIFIED); Math.max(0, MeasureSpec.getSize(parentHeightMeasureSpec) - usedTotal), MeasureSpec.UNSPECIFIED); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); } } Loading Loading
core/java/android/widget/HorizontalScrollView.java +30 −19 Original line number Original line Diff line number Diff line Loading @@ -325,16 +325,24 @@ public class HorizontalScrollView extends FrameLayout { if (getChildCount() > 0) { if (getChildCount() > 0) { final View child = getChildAt(0); final View child = getChildAt(0); int width = getMeasuredWidth(); final int widthPadding; if (child.getMeasuredWidth() < width) { final int heightPadding; final FrameLayout.LayoutParams lp = (LayoutParams) child.getLayoutParams(); final FrameLayout.LayoutParams lp = (LayoutParams) child.getLayoutParams(); final int targetSdkVersion = getContext().getApplicationInfo().targetSdkVersion; if (targetSdkVersion >= Build.VERSION_CODES.M) { widthPadding = mPaddingLeft + mPaddingRight + lp.leftMargin + lp.rightMargin; heightPadding = mPaddingTop + mPaddingBottom + lp.topMargin + lp.bottomMargin; } else { widthPadding = mPaddingLeft + mPaddingRight; heightPadding = mPaddingTop + mPaddingBottom; } int childHeightMeasureSpec = getChildMeasureSpec(heightMeasureSpec, mPaddingTop int desiredWidth = getMeasuredWidth() - widthPadding; + mPaddingBottom, lp.height); if (child.getMeasuredWidth() < desiredWidth) { width -= mPaddingLeft; final int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec( width -= mPaddingRight; desiredWidth, MeasureSpec.EXACTLY); int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY); final int childHeightMeasureSpec = getChildMeasureSpec( heightMeasureSpec, heightPadding, lp.height); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); } } } } Loading Loading @@ -1235,17 +1243,17 @@ public class HorizontalScrollView extends FrameLayout { } } @Override @Override protected void measureChild(View child, int parentWidthMeasureSpec, int parentHeightMeasureSpec) { protected void measureChild(View child, int parentWidthMeasureSpec, int parentHeightMeasureSpec) { ViewGroup.LayoutParams lp = child.getLayoutParams(); ViewGroup.LayoutParams lp = child.getLayoutParams(); int childWidthMeasureSpec; final int horizontalPadding = mPaddingLeft + mPaddingRight; int childHeightMeasureSpec; final int childWidthMeasureSpec = MeasureSpec.makeSafeMeasureSpec( Math.max(0, MeasureSpec.getSize(parentWidthMeasureSpec) - horizontalPadding), childHeightMeasureSpec = getChildMeasureSpec(parentHeightMeasureSpec, mPaddingTop MeasureSpec.UNSPECIFIED); + mPaddingBottom, lp.height); childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); final int childHeightMeasureSpec = getChildMeasureSpec(parentHeightMeasureSpec, mPaddingTop + mPaddingBottom, lp.height); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); } } Loading @@ -1257,8 +1265,11 @@ public class HorizontalScrollView extends FrameLayout { final int childHeightMeasureSpec = getChildMeasureSpec(parentHeightMeasureSpec, final int childHeightMeasureSpec = getChildMeasureSpec(parentHeightMeasureSpec, mPaddingTop + mPaddingBottom + lp.topMargin + lp.bottomMargin mPaddingTop + mPaddingBottom + lp.topMargin + lp.bottomMargin + heightUsed, lp.height); + heightUsed, lp.height); final int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec( final int usedTotal = mPaddingLeft + mPaddingRight + lp.leftMargin + lp.rightMargin + lp.leftMargin + lp.rightMargin, MeasureSpec.UNSPECIFIED); widthUsed; final int childWidthMeasureSpec = MeasureSpec.makeSafeMeasureSpec( Math.max(0, MeasureSpec.getSize(parentWidthMeasureSpec) - usedTotal), MeasureSpec.UNSPECIFIED); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); } } Loading
core/java/android/widget/ScrollView.java +21 −17 Original line number Original line Diff line number Diff line Loading @@ -350,12 +350,10 @@ public class ScrollView extends FrameLayout { if (getChildCount() > 0) { if (getChildCount() > 0) { final View child = getChildAt(0); final View child = getChildAt(0); final int height = getMeasuredHeight(); if (child.getMeasuredHeight() < height) { final int widthPadding; final int widthPadding; final int heightPadding; final int heightPadding; final FrameLayout.LayoutParams lp = (LayoutParams) child.getLayoutParams(); final int targetSdkVersion = getContext().getApplicationInfo().targetSdkVersion; final int targetSdkVersion = getContext().getApplicationInfo().targetSdkVersion; final FrameLayout.LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (targetSdkVersion >= VERSION_CODES.M) { if (targetSdkVersion >= VERSION_CODES.M) { widthPadding = mPaddingLeft + mPaddingRight + lp.leftMargin + lp.rightMargin; widthPadding = mPaddingLeft + mPaddingRight + lp.leftMargin + lp.rightMargin; heightPadding = mPaddingTop + mPaddingBottom + lp.topMargin + lp.bottomMargin; heightPadding = mPaddingTop + mPaddingBottom + lp.topMargin + lp.bottomMargin; Loading @@ -364,10 +362,12 @@ public class ScrollView extends FrameLayout { heightPadding = mPaddingTop + mPaddingBottom; heightPadding = mPaddingTop + mPaddingBottom; } } final int desiredHeight = getMeasuredHeight() - heightPadding; if (child.getMeasuredHeight() < desiredHeight) { final int childWidthMeasureSpec = getChildMeasureSpec( final int childWidthMeasureSpec = getChildMeasureSpec( widthMeasureSpec, widthPadding, lp.width); widthMeasureSpec, widthPadding, lp.width); final int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec( final int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec( height - heightPadding, MeasureSpec.EXACTLY); desiredHeight, MeasureSpec.EXACTLY); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); } } } } Loading Loading @@ -1268,9 +1268,10 @@ public class ScrollView extends FrameLayout { childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, mPaddingLeft childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, mPaddingLeft + mPaddingRight, lp.width); + mPaddingRight, lp.width); final int verticalPadding = mPaddingTop + mPaddingBottom; childHeightMeasureSpec = MeasureSpec.makeSafeMeasureSpec( childHeightMeasureSpec = MeasureSpec.makeSafeMeasureSpec( MeasureSpec.getSize(parentHeightMeasureSpec), MeasureSpec.UNSPECIFIED); Math.max(0, MeasureSpec.getSize(parentHeightMeasureSpec) - verticalPadding), MeasureSpec.UNSPECIFIED); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); } } Loading @@ -1283,8 +1284,11 @@ public class ScrollView extends FrameLayout { final int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, final int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, mPaddingLeft + mPaddingRight + lp.leftMargin + lp.rightMargin mPaddingLeft + mPaddingRight + lp.leftMargin + lp.rightMargin + widthUsed, lp.width); + widthUsed, lp.width); final int usedTotal = mPaddingTop + mPaddingBottom + lp.topMargin + lp.bottomMargin + heightUsed; final int childHeightMeasureSpec = MeasureSpec.makeSafeMeasureSpec( final int childHeightMeasureSpec = MeasureSpec.makeSafeMeasureSpec( MeasureSpec.getSize(parentHeightMeasureSpec), MeasureSpec.UNSPECIFIED); Math.max(0, MeasureSpec.getSize(parentHeightMeasureSpec) - usedTotal), MeasureSpec.UNSPECIFIED); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); } } Loading