Simple android lib for hiding out views by draging them out of screen in the set direction.
Also provides methods for hiding and showing them manually.
Simply add the following dependency to your build.gradle file:
compile 'cz.martinforejt:swipetohidelayout:1.0.4'
Work with SwipeToHideLayout like with android FrameLayout.
Direction must be set (xml or setDirection(int)
) or exception will be thrown!
The layout must be aligned to side that is defined by direction. The width/height can not be MATCH_PARENT
in sliding direction.
<cz.martinforejt.swipetohidelayout.SwipeToHideLayout
android:id="@+id/layout_top"
android:layout_width="match_parent"
android:layout_height="160dp"
android:layout_alignParentTop="true"
app:direction="top">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/swipe_me_top" />
</cz.martinforejt.swipetohidelayout.SwipeToHideLayout>
final SwipeToHideLayout top = findViewById(R.id.layout_top);
top.setOnSwipeChangeListener(new OnSwipeChangeListener() {
@Override
public void onSwipeChange(boolean visible, SwipeHideable swipeHideable) {
// catch swipe
}
});
direction - drag direction (left, top, right, bottom)
enabled - is dragging enabled (true, false)
public methods from SwipeHideable.java