Created
February 26, 2019 20:01
-
-
Save mileskrell/6ce72775ccb7eea9fc8a5d8a5db7b316 to your computer and use it in GitHub Desktop.
An AppBarLayout.Behavior that ignores dragging on the AppBarLayout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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