Make AbsListViews remeasure children after rotation
Fixes issues in Settings and other places where TextView separators
aren't resized properly after a rotation
Change-Id: Id5c53d4c5e6621e79e723ec2c300c8a43f12e379
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index ec7424ba..e901cc5 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -1160,6 +1160,14 @@
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
mInLayout = true;
+ if (changed) {
+ int childCount = getChildCount();
+ for (int i = 0; i < childCount; i++) {
+ getChildAt(i).forceLayout();
+ }
+ mRecycler.markChildrenDirty();
+ }
+
layoutChildren();
mInLayout = false;
@@ -4142,6 +4150,25 @@
mCurrentScrap = scrapViews[0];
mScrapViews = scrapViews;
}
+
+ public void markChildrenDirty() {
+ if (mViewTypeCount == 1) {
+ final ArrayList<View> scrap = mCurrentScrap;
+ final int scrapCount = scrap.size();
+ for (int i = 0; i < scrapCount; i++) {
+ scrap.get(i).forceLayout();
+ }
+ } else {
+ final int typeCount = mViewTypeCount;
+ for (int i = 0; i < typeCount; i++) {
+ final ArrayList<View> scrap = mScrapViews[i];
+ final int scrapCount = scrap.size();
+ for (int j = 0; j < scrapCount; j++) {
+ scrap.get(j).forceLayout();
+ }
+ }
+ }
+ }
public boolean shouldRecycleViewType(int viewType) {
return viewType >= 0;