Merge "Account for margins in ScrollView onMeasure() when filling viewport" into mnc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
42cc892be1
@@ -18,6 +18,7 @@ package android.widget;
|
|||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.os.Build.VERSION_CODES;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import com.android.internal.R;
|
import com.android.internal.R;
|
||||||
@@ -349,17 +350,24 @@ public class ScrollView extends FrameLayout {
|
|||||||
|
|
||||||
if (getChildCount() > 0) {
|
if (getChildCount() > 0) {
|
||||||
final View child = getChildAt(0);
|
final View child = getChildAt(0);
|
||||||
int height = getMeasuredHeight();
|
final int height = getMeasuredHeight();
|
||||||
if (child.getMeasuredHeight() < height) {
|
if (child.getMeasuredHeight() < height) {
|
||||||
|
final int widthPadding;
|
||||||
|
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 >= VERSION_CODES.MNC) {
|
||||||
|
widthPadding = mPaddingLeft + mPaddingRight + lp.leftMargin + lp.rightMargin;
|
||||||
|
heightPadding = mPaddingTop + mPaddingBottom + lp.topMargin + lp.bottomMargin;
|
||||||
|
} else {
|
||||||
|
widthPadding = mPaddingLeft + mPaddingRight;
|
||||||
|
heightPadding = mPaddingTop + mPaddingBottom;
|
||||||
|
}
|
||||||
|
|
||||||
int childWidthMeasureSpec = getChildMeasureSpec(widthMeasureSpec,
|
final int childWidthMeasureSpec = getChildMeasureSpec(
|
||||||
mPaddingLeft + mPaddingRight, lp.width);
|
widthMeasureSpec, widthPadding, lp.width);
|
||||||
height -= mPaddingTop;
|
final int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(
|
||||||
height -= mPaddingBottom;
|
height - heightPadding, MeasureSpec.EXACTLY);
|
||||||
int childHeightMeasureSpec =
|
|
||||||
MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
|
|
||||||
|
|
||||||
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
|
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user