Git Product home page Git Product logo

reboundlayout's Introduction

自定义回弹布局

详情戳这里

效果一:
ReBoundLayout

Step 1

<com.zzh12138.reboundlayout.rebound.ReBoundLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/reBoundLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:resistance="1"
    app:reBoundOrientation="horizontal"
    android:background="#80000000"
    tools:context=".rebound.ReBoundActivity">

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</com.zzh12138.reboundlayout.rebound.ReBoundLayout>

自定义属性相关:

    <declare-styleable name="ReBoundLayout">
        <attr name="reBoundOrientation" format="enum">
            <enum name="horizontal" value="0" />
            <enum name="vertical" value="1" />
        </attr>
        <attr name="resistance" format="float" />
        <attr name="reBoundDuration" format="integer" />
    </declare-styleable>
  • innerView 移动的View
  • resistance 阻力系数
  • orientation 回弹方向
  • mDuration 回弹时长
  • resetDistance 回弹阈值
  • isNeedReset 手指抬起时距离大于阈值是否需要回弹

也可调用set方法进行修改 Step 2

reBoundLayout.setOnBounceDistanceChangeListener(new OnBounceDistanceChangeListener() {
            @Override
            public void onDistanceChange(int distance, int direction) {
                //移动回调
            }

            @Override
            public void onFingerUp(int distance, int direction) {
               //手指松开回调
            }
        });

PS:Kotlin请使用 ReBoundLayoutKt

效果二:
DragZoomLayout

Step 1

<com.zzh12138.reboundlayout.drag.DragZoomLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#00000000"
    app:interceptOrientation="vertical">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</com.zzh12138.reboundlayout.drag.DragZoomLayout>

自定义属性相关:

    <declare-styleable name="DragZoomLayout">
        <attr name="interceptOrientation" format="enum">
            <enum name="horizontal" value="0" />
            <enum name="vertical" value="1" />
        </attr>
        <attr name="reSetDuration" format="integer" />
    </declare-styleable>
  • innerView 移动的View
  • resistance 阻力系数
  • orientation 回弹方向
  • mDuration 回弹时长
  • resetDistance 回弹阈值
  • isNeedReset 手指抬起时距离大于阈值是否需要回弹
  • mMinRadius 圆的最小半径
  • mMaxRadius 圆的最大半径

也可调用set方法进行修改 Step 2

        dragLayout.setOnDragDistanceChangeListener(new OnDragDistanceChangeListener() {
            @Override
            public void onDistanceChange(int translationX, int translationY, int direction) {
                //距离改变
            }

            @Override
            public void onFingerUp(int translationX, int translationY, int direction) {
              //手指抬起
            }
        });

PS:Kotlin请使用 DragZoomLayoutKt

License

MIT

reboundlayout's People

Contributors

zzh12138 avatar

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.