This is a ViewGroup that provides a sideslip function. You can set its sliding direction: left, right, up, down. In addition, it also resolves the issue of sliding conflicts, so you can use it in your RecyclerView or ListView.

preview

Download Demo here

Rely on

Step 1. Add the JitPack repository

Add it in your root build.gradle at the end of repositories:

  allprojects {
  	repositories {
  		...
  		maven { url 'https://jitpack.io' }
  	}
  }Copy the code

Step 2. Add dependencies

Dependencies {the compile 'com. Making. Qiaoyunrui: SlipperyLayout: v1.0'}Copy the code

usage

Add to your layout file:

<com.juhezi.slipperylayout.SlipperyLayout
        android:id="@+id/sl_test"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_margin="8dp"
        app:content="@layout/content"
        app:lock="false"
        app:menu="@layout/menu"
        app:slideGravity="top" />Copy the code

Provided attributes:

  • Content: A reference to the content layout

  • Menu: reference to the menu layout

  • SlideGravity: Slide direction (left, right, up, down)

  • Lock: Indicates whether to lock or slide

You can control the opening and closing of SlipperyLayout in your code

SlipperyLayout mSlTest = (SlipperyLayout) findViewById(R.id.sl_test); Button mBtnOpen = (Button) findViewById(R.id.btn_open); Button mBtnClose = (Button) findViewById(R.id.btn_close); mBtnOpen.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mSlTest.openMenuView();  Open menu view}}); mBtnClose.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mSlTest.closeMenuView(); // Close menu view}});Copy the code

Methods provided:

  • Public void setSlideGravity(@slidegravity int SlideGravity), set the sliding direction

  • Public Boolean isLock(), whether to lock swipe

  • Public void setLock(Boolean lock), setLock(true, SlipperyLayout cannot slide)

  • Public Boolean isMenuViewVisible(), get menu view visibility

  • Public View getMenuView() to get the menu View

  • Public View getContentView() to get the content View

  • Public void openMenuView() opens the menu view

  • Public void closeMenuView(), closes the menu view

Pay attention to

SlipperyLayout supports Padding and Margin, but does not support elevation.

If you have any problem in using it, please send an issue or email to me, my email is [email protected].