diff options
| author | Yigit Boyar <yboyar@google.com> | 2016-05-31 19:20:19 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-05-31 19:20:21 +0000 |
| commit | bb039d2f17d61b96c88d2cae445a53a642fb421f (patch) | |
| tree | 6a7e251f56d328948fb813149ccf8cd93e849ec8 /core/java/android | |
| parent | 9801a9269c6fcdc9996fb752b2421eb409fc3b09 (diff) | |
| parent | 51b5caf902a6bedc016096abc7ef9e5d0e1a68c7 (diff) | |
Merge "Invalidate child bounds when AbsListView bounds change" into nyc-dev
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/widget/AbsListView.java | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index 28ade80a260e..b331be72b4cf 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -2675,19 +2675,49 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te return (mGroupFlags & CLIP_TO_PADDING_MASK) == CLIP_TO_PADDING_MASK ? 0 : mPaddingBottom; } + /** + * @hide + */ @Override - protected void onSizeChanged(int w, int h, int oldw, int oldh) { - if (getChildCount() > 0) { - mDataChanged = true; - rememberSyncState(); + protected void internalSetPadding(int left, int top, int right, int bottom) { + super.internalSetPadding(left, top, right, bottom); + if (isLayoutRequested()) { + handleBoundsChange(); } + } + @Override + protected void onSizeChanged(int w, int h, int oldw, int oldh) { + handleBoundsChange(); if (mFastScroll != null) { mFastScroll.onSizeChanged(w, h, oldw, oldh); } } /** + * Called when bounds of the AbsListView are changed. AbsListView marks data set as changed + * and force layouts all children that don't have exact measure specs. + * <p> + * This invalidation is necessary, otherwise, AbsListView may think the children are valid and + * fail to relayout them properly to accommodate for new bounds. + */ + void handleBoundsChange() { + final int childCount = getChildCount(); + if (childCount > 0) { + mDataChanged = true; + rememberSyncState(); + for (int i = 0; i < childCount; i++) { + final View child = getChildAt(i); + final ViewGroup.LayoutParams lp = child.getLayoutParams(); + // force layout child unless it has exact specs + if (lp == null || lp.width < 1 || lp.height < 1) { + child.forceLayout(); + } + } + } + } + + /** * @return True if the current touch mode requires that we draw the selector in the pressed * state. */ |
