Fix UI disordered when starting activity in background
ViewPager can't get its actual height when updating in background.
Call super.onMeasure() at first to retrive child count and then call
setMeasuredDimension().
Bug: 135406087
Test: Manual test
Change-Id: I58430d01b324785d9d6f900d31791abf67ebceb2
diff --git a/src/com/android/wallpaper/livepicker/widget/ConstraintViewPager.java b/src/com/android/wallpaper/livepicker/widget/ConstraintViewPager.java
index 985cad6..f59b0b9 100644
--- a/src/com/android/wallpaper/livepicker/widget/ConstraintViewPager.java
+++ b/src/com/android/wallpaper/livepicker/widget/ConstraintViewPager.java
@@ -50,6 +50,8 @@
*/
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
int maxChildHeight = 0;
int infoChildHeight = 0;
int infoTopPadding = 0;
@@ -81,9 +83,6 @@
}
}
- if (maxChildHeight != 0) {
- heightMeasureSpec = MeasureSpec.makeMeasureSpec(maxChildHeight, MeasureSpec.EXACTLY);
- }
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), maxChildHeight);
}
}