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