Skip to content

ArronYee/DrawerLayout

Repository files navigation

DrawerLayout

img

What's the DrawerLayout

When you want get a flip drawer layout which both have horizon and vertical ,that it is.

In this folder repository contains:

  1. /app a sample example for DrawerLayout.
  2. /drawerLayout the libs code.
  3. demo

Table of Contents

Partial-code-description

	<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。

Install

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'
	}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages