Skip to content

Instantly share code, notes, and snippets.

@mileskrell
Created February 26, 2019 20:01
Show Gist options
  • Save mileskrell/6ce72775ccb7eea9fc8a5d8a5db7b316 to your computer and use it in GitHub Desktop.
Save mileskrell/6ce72775ccb7eea9fc8a5d8a5db7b316 to your computer and use it in GitHub Desktop.
An AppBarLayout.Behavior that ignores dragging on the AppBarLayout
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.design.widget.AppBarLayout;
import android.util.AttributeSet;
/**
* When used as the LayoutBehavior of an AppBarLayout, prevents
* scrolling by dragging on the AppBarLayout itself
*
* From https://stackoverflow.com/a/46120228
*/
public class FixedAppBarLayoutBehavior extends AppBarLayout.Behavior {
public FixedAppBarLayoutBehavior(Context context, AttributeSet attrs) {
super(context, attrs);
setDragCallback(new DragCallback() {
@Override public boolean canDrag(@NonNull AppBarLayout appBarLayout) {
return false;
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment