summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKunhung Li <kunhungli@google.com>2019-02-26 14:39:21 +0800
committerKunhung Li <kunhungli@google.com>2019-02-26 15:34:47 +0800
commit0af454ff0a558df877b669320a7e34074fc240c6 (patch)
tree0c0472c751819dc99d53bbaf07d8fd51049d4007 /src
parentda5804645ed5800b9faaaeedaeed2b1ce2219bd3 (diff)
downloadandroid_packages_wallpapers_LivePicker-0af454ff0a558df877b669320a7e34074fc240c6.tar.gz
android_packages_wallpapers_LivePicker-0af454ff0a558df877b669320a7e34074fc240c6.tar.bz2
android_packages_wallpapers_LivePicker-0af454ff0a558df877b669320a7e34074fc240c6.zip
Align info and setting tab to the same height
It will feel tab jumping while switching to different tab, which causes from info tab and customize tab's height are not the same. Visit all child views first and then determine the maximum height for ViewPager. Bug: 126301901 Test: Manual Test Change-Id: Iada213a96622179b201a96b36ee551c6732dd5cc
Diffstat (limited to 'src')
-rw-r--r--src/com/android/wallpaper/livepicker/widget/ConstraintViewPager.java22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/com/android/wallpaper/livepicker/widget/ConstraintViewPager.java b/src/com/android/wallpaper/livepicker/widget/ConstraintViewPager.java
index 8948bb4..c4dcf09 100644
--- a/src/com/android/wallpaper/livepicker/widget/ConstraintViewPager.java
+++ b/src/com/android/wallpaper/livepicker/widget/ConstraintViewPager.java
@@ -25,8 +25,8 @@ import androidx.annotation.Nullable;
import androidx.viewpager.widget.ViewPager;
/**
- * When ConstraintViewPager is being measured, it will calculate height of the currently selected
- * page and makes itself be the same height exactly.
+ * When ConstraintViewPager is being measured, it will get all height of pages and makes itself
+ * height as the same as the maximum height.
*/
public class ConstraintViewPager extends ViewPager {
@@ -39,20 +39,24 @@ public class ConstraintViewPager extends ViewPager {
}
/**
- * Calculates the measured height of the selected page and makes itself be the same height.
+ * Visit all child views first and then determine the maximum height for ViewPager.
*/
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- final View pageView = getChildAt(getCurrentItem());
- if (pageView != null) {
- pageView.measure(widthMeasureSpec,
+ int maxChildHeight = 0;
+ for (int i = 0; i < getChildCount(); i++) {
+ View view = getChildAt(i);
+ view.measure(widthMeasureSpec,
MeasureSpec.makeMeasureSpec(0 /* size */, MeasureSpec.UNSPECIFIED));
- if (pageView.getMeasuredHeight() != 0) {
- heightMeasureSpec = MeasureSpec.makeMeasureSpec(pageView.getMeasuredHeight(),
- MeasureSpec.EXACTLY);
+ int childHeight = view.getMeasuredHeight();
+ if (childHeight > maxChildHeight) {
+ maxChildHeight = childHeight;
}
}
+ if (maxChildHeight != 0) {
+ heightMeasureSpec = MeasureSpec.makeMeasureSpec(maxChildHeight, MeasureSpec.EXACTLY);
+ }
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}