Giter Club home page Giter Club logo

bouncescrollview's Introduction

BounceScrollView

API License

logo

🎨An Android warpped ScrollView, which works just like the UIScrollView in iOS when the user tries to scroll it beyond its content.🎨


Features

  • ♠️Maximum adaptability. It supports the horizontal and the vertical direction, and extends the NestScrollView. So it not only can work just like the ScrollView and the HorizontalScrollView, but also can work properly with Nest Scrolling.
  • ♥️Customizable damping coefficient (easier or harder to over scroll). The incremental damping or constant damping can be chose during the over-scrolling.
  • ♣️Customizable bounce delay, the duration of the restoring animation.
  • ♦️Customizable interpolator, the rate of change of the restoring animation.

Download

root project:build.gradle

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

app:build.gradle

  dependencies {
     implementation 'com.github.woxingxiao:BounceScrollView:LATEST_VERSION'
  }

Usage

<?xml version="1.0" encoding="utf-8"?>
<com.xw.repo.widget.BounceScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

          <!-- The ConstraintLayout can be replaced by FrameLayout, LinearLayout, etc. -->
          <!-- Your content view goes here. -->

     </android.support.constraint.ConstraintLayout>
</com.xw.repo.widget.BounceScrollView>

Listener to the scrolling event of content of the BounceScrollView:

mBounceScrollView.setOnScrollListener(new OnScrollListener() {
    @Override
    public void onScrolling(int scrollX, int scrollY) {

    }
});

Listener to the over-scrolling event of the BounceScrollView:

mBounceScrollView.setOnOverScrollListener(new OnOverScrollListener() {
    @Override
    public void onOverScrolling(boolean fromStart, int overScrolledDistance) {

    }
});

Attributes

Attr Format Descrption
damping float The damping coefficient. The greater the value, the hard it is to over scroll. Defalut: 2.0
scrollOrientation enum The children layout direction. Default: vertical
incrementalDamping boolean Whether the damping coefficient growing with the distance or not. Default: true
bounceDelay long The duration of restoring animation. Default: 400(ms)
triggerOverScrollThreshold int The length in pixel to trigger over-scrolling. Default: 20(px)

It took me an amount of time to adjust the parameters pixel by pixel, in order to achieve the best experience I think.:beers:


🍰If the attr damping is set to 2.0, the over-scrolling effort is almost the same as UIScrollView in iOS.
🍰The interpolator of the restoring animation is customizable. You can do it by:

mBounceScrollView.setBounceInterpolator(new YourCustomizedInterpolator());

Thanks to the repo EasingInterpolator, there are multiple choices to choose.


Most of the resources in the sample come from gameofthrones.com. Everybody likes GoT, right? 😉

License

   Copyright 2018 woxingxiao

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

bouncescrollview's People

Contributors

woxingxiao avatar

Watchers

 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.