Last active
March 7, 2017 14:04
-
-
Save davidtcdeveloper/2521bb82c3c0354babc810ba6a60aeb8 to your computer and use it in GitHub Desktop.
Disables nested scroll and, by consequence, the expand/collapse from AppBar. Don't forget to manually expand/collapse app bar in code.
This file contains hidden or 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.design.widget.AppBarLayout; | |
| import android.support.design.widget.CoordinatorLayout; | |
| import android.util.AttributeSet; | |
| import android.view.View; | |
| public class NestedScrollAppBarBehavior extends AppBarLayout.Behavior { | |
| private boolean nestedScrollEnabled; | |
| public DisableableAppBarLayoutBehavior() { | |
| super(); | |
| } | |
| public DisableableAppBarLayoutBehavior(Context context, AttributeSet attrs) { | |
| super(context, attrs); | |
| } | |
| public void setNestedScrollEnabled(boolean enabled) { | |
| nestedScrollEnabled = enabled; | |
| } | |
| @Override | |
| public boolean onStartNestedScroll( | |
| CoordinatorLayout parent, | |
| AppBarLayout child, | |
| View directTargetChild, | |
| View target, | |
| int nestedScrollAxes) { | |
| return nestedScrollEnabled && | |
| super.onStartNestedScroll( | |
| parent, | |
| child, | |
| directTargetChild, | |
| target, | |
| nestedScrollAxes); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment