Disclaimer: This library is no longer maintained use at your own risk.
Modification of the BottomSheetBehavior with Anchor state.
Fine more about it at the medium blog post.
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add AnchorSheetBehavior dependency:
dependencies {
compile 'com.github.marcelpinto:AnchorSheetBehavior:master-SNAPSHOT'
}
The behavior is an extension of the Android support design, thus the usage is the same. The only addition is two extra states:
- STATE_ANCHOR: push the bottom sheet to an anchor state defined by Anchor offset
- STATE_FORCE_HIDE: force the bottom sheet to hide regardless of hideable flag
/**
* Set the offset for the anchor state. Number between 0..1
* i.e: Anchor the panel at 1/3 of the screen: setAnchorOffset(0.25)
*
* @param threshold {@link Float} from 0..1
*/
public void setAnchorOffset(float threshold) {
this.mAnchorThreshold = threshold;
this.mAnchorOffset = (int) Math.max(mParentHeight * mAnchorThreshold, mMinOffset);
}
For more usage see Android docs
Copyright 2015 Marcel Pintó Biescas
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.