Skip to content

Sanku-Yogesh/AnchorSheetBehavior

 
 

Repository files navigation

AnchorSheetBehavior

Quality Gate Status Build

Modification of the BottomSheetBehavior with Anchor state.

Fine more about it at the medium blog post.

Add AnchorSheetBehavior Dependency

  1. For using AnchorSheetBehavior module in sample app, include the source code and add the below dependencies in entry/build.gradle to generate hap/support.har.
	dependencies {
		implementation project(':anchorsheetlayout')
        	implementation fileTree(dir: 'libs', include: ['*.har'])
        	testCompile 'junit:junit:4.12'
	}
  1. For using AnchorSheetBehavior in separate application using har file, add the har file in the entry/libs folder and add the dependencies in entry/build.gradle file.
	dependencies {
		implementation fileTree(dir: 'libs', include: ['*.har'])
		testCompile 'junit:junit:4.12'
	}

  1. For using AnchorSheetBehavior from a remote repository in separate application, add the below dependencies in entry/build.gradle file.
	dependencies {
		implementation 'dev.applibgroup:anchorsheetlayout:1.0.0'
		testCompile 'junit:junit:4.12'
	}

Usage

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

License

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.

About

Repository for AnchorSheetBehavior Library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%