Giter Site home page Giter Site logo

slipperylayout's Introduction

SlipperyLayout

minSdkVersion 21

This is a simple ViewGroup that support sliding to show menu, you can set the sliding direction, left、right、top、bottom.

In addition, it also solved the problem of the sliding conflict, so you can put it on your RecyclerView or in the ListView.

Preview

Download the demo

dependencies

Step 1. Add the JitPack repository to your build file

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

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

Step 2. Add the dependency

dependencies {
         compile 'com.github.qiaoyunrui:SlipperyLayout:v1.1'
}

Usage

Add to your layout xml-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" />

Properties provided:

  • content: the layout of content

  • menu: the layout of menu

  • slideGravity: the sliding direction

  • lock: if true,can not be slided.

Control SlipperyLayout opened or closed in the 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();   //opene the menu
    }
});
mBtnClose.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        mSlTest.closeMenuView();  //close the menu
    }
});

Methods provided:

  • public void setSlideGravity(@SlideGravity int slideGravity),set the sliding direction

  • public boolean isLock(),whether the lock slide

  • public void setLock(boolean lock),set the lock (if set to true, SlipperyLayout cannot slide)

  • public boolean isMenuViewVisible(),get the visibility of menu view

  • public View getMenuView(),get the menu view

  • public View getContentView(),get the content view

  • public void openMenuView(),open menu

  • public void closeMenuView(),close menu

  • public void setSlideListener(),set the listener

  • public void removeSlideListener(),remove the setted listener

Methods provided in the SlideListener

  • public void onSliding(View menuView, int dx, int dy)

  • public void onMenuOpened(View menuView)

  • public void onMenuClosed(View menuView)

  • public void onStateChanged(@SlipperyLayout.State int oldState, @SlipperyLayout.State int newState)

Attention

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

If you met what problem in use process, please create the issue or send an email to me, my email is [email protected].

中文 README

slipperylayout's People

Contributors

qiaoyunrui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

wangjishan

slipperylayout's Issues

添加状态改变监听器

可否添加一个 监听器:当侧滑部分开始滑动显示时调用,用于RecyclerView打开其他条目是,关闭上次打开的条目菜单。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.