diff options
author | Maurice Lam <yukl@google.com> | 2015-05-07 14:24:05 -0700 |
---|---|---|
committer | Maurice Lam <yukl@google.com> | 2015-05-07 15:18:06 -0700 |
commit | 3c154790e7c6668c60237bcde0fc6f5fa22884b0 (patch) | |
tree | c4663bb33ae1c673e69251d0e0941ea5e8099e6e /library/main/src/com/android | |
parent | 0332b43621349b38c33457492b0a70fba37a04a0 (diff) | |
download | setupwizard-3c154790e7c6668c60237bcde0fc6f5fa22884b0.tar.gz |
Sanity check margins before applying
Check that margins are smaller than the height of the view before
applying the margins when setting the IME inset view.
Bug: 20891203
Change-Id: I91420ac3f9aa97a1d6034545e2f507a5a71a0ca8
Diffstat (limited to 'library/main/src/com/android')
-rw-r--r-- | library/main/src/com/android/setupwizardlib/util/SystemBarHelper.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/library/main/src/com/android/setupwizardlib/util/SystemBarHelper.java b/library/main/src/com/android/setupwizardlib/util/SystemBarHelper.java index 4cba014..ff6e05f 100644 --- a/library/main/src/com/android/setupwizardlib/util/SystemBarHelper.java +++ b/library/main/src/com/android/setupwizardlib/util/SystemBarHelper.java @@ -219,19 +219,27 @@ public class SystemBarHelper { @Override public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) { + int bottomInset = insets.getSystemWindowInsetBottom(); final int bottomMargin = Math.max( insets.getSystemWindowInsetBottom() - mNavigationBarHeight, 0); - ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) view.getLayoutParams(); - lp.setMargins(lp.leftMargin, lp.topMargin, lp.rightMargin, bottomMargin); - view.requestLayout(); + final ViewGroup.MarginLayoutParams lp = + (ViewGroup.MarginLayoutParams) view.getLayoutParams(); + // Check that we have enough space to apply the bottom margins before applying it. + // Otherwise the framework may think that the view is empty and exclude it from layout. + if (bottomMargin < lp.bottomMargin + view.getHeight()) { + lp.setMargins(lp.leftMargin, lp.topMargin, lp.rightMargin, bottomMargin); + view.setLayoutParams(lp); + bottomInset = 0; + } + return insets.replaceSystemWindowInsets( insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), - 0 /* bottom */ + bottomInset ); } } |