When you want get a flip drawer layout which both have horizon and vertical ,that it is.
In this folder repository contains:
- /app a sample example for DrawerLayout.
- /drawerLayout the libs code.
- demo
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.arronyee.drawerlayout.DrawerWrapperLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.arronyee.drawerlayout.DrawerWrapperLayout>
</LinearLayout>
Put DrawerWrapperLayout into your XML.
drawerWrapperLayout = findViewById(R.id.drawer_layout);
drawerWrapperLayout.addDrawerSwiperLayout();
Your need to invoke addDrawerSwiperLayout() to get first start.
@Override
public void onChange(DrawerSwiperLayout drawerSwiperLayout, boolean isBackGroudView, int direction) {
DrawerSwiperLayout view = addDrawerSwiperLayout();
if (onChangeViewLevel!=null){
onChangeViewLevel.onChange(view,drawerSwiperLayout,direction);
}
}
//-----//
public static final int DIRECTION_leftRight = 11;
public static final int DIRECTION_rightLeft = 22;
public static final int DIRECTION_topBottom = 33;
public static final int DIRECTION_bottomTop = 44;
You can set onChange listener to get the direction when flip view.
public void translationY(final boolean center){
int dist = 0;
int direction = 0;
if (center){
dist = getTop()-dragView.getTop();
direction = getDirection();
}else{
if (bottomTop){
dist = getBottom() -dragView.getTop();
}else if(topBottom){
dist = getTop() -dragView.getBottom() ;
}
}
final AnimatorSet translationAnimatorSet = new AnimatorSet();
translationAnimatorSet.play(ObjectAnimator.ofFloat(dragView, "translationY", dist)
.setDuration(500));
final int finalDirection = direction;
translationAnimatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
isAnim = false;
if (center) {
freezeCenter();
if (onChangeViewLevel!=null){
onChangeViewLevel.onChange(DrawerSwiperLayout.this,true, finalDirection);
}
}
}
});
translationAnimatorSet.start();
isAnim = true;
}
It use ObjectAnimator to achieve property animation。
In your project build.gradle:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
In your needed module
dependencies {
implementation 'com.github.ArronYee:Form:0.0.3'
}