diff --git a/library/src/main/java/com/trafi/anchorbottomsheetbehavior/AnchorBottomSheetBehavior.java b/library/src/main/java/com/trafi/anchorbottomsheetbehavior/AnchorBottomSheetBehavior.java index 0424bce..5b3f141 100644 --- a/library/src/main/java/com/trafi/anchorbottomsheetbehavior/AnchorBottomSheetBehavior.java +++ b/library/src/main/java/com/trafi/anchorbottomsheetbehavior/AnchorBottomSheetBehavior.java @@ -179,6 +179,8 @@ public void onSlide(@NonNull View bottomSheet, float slideOffset) { private boolean mSkipCollapsed; + private boolean mSkipAnchored; + private boolean mDisableExpanded; @AnchorBottomSheetBehavior.State @@ -232,6 +234,7 @@ public AnchorBottomSheetBehavior(Context context, AttributeSet attrs) { setHideable(a.getBoolean(android.support.design.R.styleable.BottomSheetBehavior_Layout_behavior_hideable, false)); setSkipCollapsed(a.getBoolean(android.support.design.R.styleable.BottomSheetBehavior_Layout_behavior_skipCollapsed, false)); + setSkipAnchored(a.getBoolean(R.styleable.AnchorBottomSheetBehavior_Layout_behavior_skipAnchored, false)); a.recycle(); a = context.obtainStyledAttributes(attrs, R.styleable.AnchorBottomSheetBehavior_Layout); @@ -597,6 +600,28 @@ public boolean getSkipCollapsed() { return mSkipCollapsed; } + /** + * Sets whether this bottom sheet should skip the anchored state when it is being collapsed from + * an expanded state or when it is being expanded from a collapsed state. + * + * @param skipAnchored True if the bottom sheet should skip the anchored state. + * @attr ref R.styleable#AnchorBottomSheetBehavior_Layout_behavior_skipAnchored + */ + public void setSkipAnchored(boolean skipAnchored) { + mSkipAnchored = skipAnchored; + } + + /** + * Sets whether this bottom sheet should skip the anchored state when it is being collapsed from + * an expanded state or when it is being expanded from a collapsed state. + * + * @return Whether the bottom sheet should skip the anchored state. + * @attr ref R.styleable#AnchorBottomSheetBehavior_Layout_behavior_skipAnchored + */ + public boolean getSkipAnchored() { + return mSkipAnchored; + } + public boolean isDisableExpanded() { return mDisableExpanded; } @@ -760,6 +785,9 @@ boolean shouldHide(View child, float yvel) { } boolean shouldExpand(View child, float yvel) { + if (mSkipAnchored) { + return true; + } int currentTop = child.getTop(); if (currentTop < mAnchorOffset) { return true; @@ -769,6 +797,9 @@ boolean shouldExpand(View child, float yvel) { } boolean shouldCollapse(View child, float yvel) { + if (mSkipAnchored) { + return true; + } int currentTop = child.getTop(); if (currentTop > mAnchorOffset) { return true; diff --git a/library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml index 457edd2..c6b484e 100644 --- a/library/src/main/res/values/attrs.xml +++ b/library/src/main/res/values/attrs.xml @@ -8,5 +8,6 @@ +