diff options
| author | Alan Viverette <alanv@google.com> | 2015-06-04 10:56:27 -0700 |
|---|---|---|
| committer | Alan Viverette <alanv@google.com> | 2015-06-04 10:56:27 -0700 |
| commit | 97e1be8ef6dfd07324c2a1e7d7f59a5658c023bb (patch) | |
| tree | f3d8da77d3c98fb84e960ddb6f3b6b4e121871d1 /core/java | |
| parent | b0a5e78fc06aeb67ac1f55832c9ceef5f92a0807 (diff) | |
| download | frameworks_base-97e1be8ef6dfd07324c2a1e7d7f59a5658c023bb.zip frameworks_base-97e1be8ef6dfd07324c2a1e7d7f59a5658c023bb.tar.gz frameworks_base-97e1be8ef6dfd07324c2a1e7d7f59a5658c023bb.tar.bz2 | |
Account for margins in ScrollView onMeasure() when filling viewport
Bug: 19247610
Change-Id: I8e43cd9c28652cd8a0fed9b896394b976c9817a9
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/widget/ScrollView.java | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java index ca57d1a..11904e1 100644 --- a/core/java/android/widget/ScrollView.java +++ b/core/java/android/widget/ScrollView.java @@ -18,6 +18,7 @@ package android.widget; import android.annotation.NonNull; import android.os.Build; +import android.os.Build.VERSION_CODES; import android.os.Parcel; import android.os.Parcelable; import com.android.internal.R; @@ -349,17 +350,24 @@ public class ScrollView extends FrameLayout { if (getChildCount() > 0) { final View child = getChildAt(0); - int height = getMeasuredHeight(); + 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; + 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, - mPaddingLeft + mPaddingRight, lp.width); - height -= mPaddingTop; - height -= mPaddingBottom; - int childHeightMeasureSpec = - MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY); - + final int childWidthMeasureSpec = getChildMeasureSpec( + widthMeasureSpec, widthPadding, lp.width); + final int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec( + height - heightPadding, MeasureSpec.EXACTLY); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); } } |
