Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c3378265 authored by Yigit Boyar's avatar Yigit Boyar Committed by android-build-merger
Browse files

Merge "Multiple fixes in ScrollView and HorizontalScrollView" into nyc-dev

am: 7de3b2d8

* commit '7de3b2d8':
  Multiple fixes in ScrollView and HorizontalScrollView

Change-Id: I00bd3b137343ffb461543beca8ea8d5c9ec1aebe
parents 4b868000 7de3b2d8
Loading
Loading
Loading
Loading
+30 −19
Original line number Original line Diff line number Diff line
@@ -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);
            }
            }
        }
        }
@@ -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);
    }
    }


@@ -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);
    }
    }
+21 −17
Original line number Original line Diff line number Diff line
@@ -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;
@@ -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);
            }
            }
        }
        }
@@ -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);
    }
    }
@@ -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);
    }
    }