Skip to content

Instantly share code, notes, and snippets.

@nasahapps
Last active August 4, 2017 02:55
Show Gist options
  • Save nasahapps/418096bfe329abdc1c5257b40ae50ebf to your computer and use it in GitHub Desktop.
Save nasahapps/418096bfe329abdc1c5257b40ae50ebf to your computer and use it in GitHub Desktop.
Reverts CollasingToolbarLayout.onMeasure()
package android.support.design.widget
import android.content.Context
import android.util.AttributeSet
public class FixedCollapsingToolbarLayout extends CollapsingToolbarLayout {
public FixedCollapsingToolbarLayout(Context context) {
this(context, null);
}
public FixedCollapsingToolbarLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// During the super call to onMeasure(), we'll save a copy of mLastInsets,
// consume the insets of mLastInsets so the super call has no insets to work with,
// then re-assign mLastInsets to what it was before the super call.
WindowInsetsCompat oldInsets = mLastInsets;
if (mLastInsets != null) {
mLastInsets = mLastInsets.consumeSystemWindowInsets();
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
mLastInsets = oldInsets;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment