Fix AppBarLayout not being drawn after rotation
Happens when someone is using configChanges="orientation".
The fix is to tickle the invalidation flag on both the view
and the parent.
BUG: 23381984
Change-Id: Iddd44c59b4a8a64eab9c339f14728b5705266bf9
diff --git a/design/src/android/support/design/widget/ViewOffsetHelper.java b/design/src/android/support/design/widget/ViewOffsetHelper.java
index 84fcc1d..a76ca9a 100644
--- a/design/src/android/support/design/widget/ViewOffsetHelper.java
+++ b/design/src/android/support/design/widget/ViewOffsetHelper.java
@@ -55,20 +55,20 @@
ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));
- // Manually invalidate the parent to make sure we get drawn pre-M
+ // Manually invalidate the view and parent to make sure we get drawn pre-M
if (Build.VERSION.SDK_INT < 23) {
- tickleParentInvalidationFlag(mView);
+ tickleInvalidationFlag(mView);
+ final ViewParent vp = mView.getParent();
+ if (vp instanceof View) {
+ tickleInvalidationFlag((View) vp);
+ }
}
}
- private static void tickleParentInvalidationFlag(View view) {
- ViewParent vp = view.getParent();
- if (vp instanceof View) {
- View parent = (View) vp;
- final float x = ViewCompat.getTranslationX(parent);
- ViewCompat.setTranslationX(parent, x + 1);
- ViewCompat.setTranslationX(parent, x);
- }
+ private static void tickleInvalidationFlag(View view) {
+ final float x = ViewCompat.getTranslationX(view);
+ ViewCompat.setTranslationY(view, x + 1);
+ ViewCompat.setTranslationY(view, x);
}
/**