GithubHelp home page GithubHelp logo

shaikhmohsink / verticalviewpager Goto Github PK

View Code? Open in Web Editor NEW

This project forked from deepakmishra/verticalviewpager

0.0 2.0 0.0 319 KB

Smooth Vertical View Pager by copying and tweaking android's ViewPager and then using it to make it vertical

Java 100.00%

verticalviewpager's Introduction

VerticalViewPager

Scroll Preview

This is a VerticalViewPager implementation for Android. It extends the default Android ViewPager to support very smooth vertical scrolling instead of horizontal scrolling. To implement this the inbuilt ViewPager should be excluded from your project.

Note: The master branch follows v26.1.0. For v27.1.1, go to branch version27.

Implementation

Add the following lines inside the dependencies part of your build.gradle file to exclude the default Android ViewPager from your project

dependencies {
	configurations {
		all*.exclude module: "support-core-ui"
	}
}

Now copy the files from the android/support/v4 folder of support-core-ui v26.1.0 in this projects java folder and add them to you personal project's java folder. This should be done to supplement the code that was excluded above.

Also copy the VerticalViewPager file from this project's com/viewpager folder and add it to your project.

While adding a ViewPager to your layout xml file, add the new VerticalViewPager that you included from this project instead of the default Android ViewPager, like this :

<com.viewpager.VerticalViewPager
	android:id="@+id/view_pager"
	android:layout_width="match_parent"
	android:layout_height="match_parent" />

While adding a reference to the VerticalViewPager to your java file, you may use it the same way you would use a normal ViewPager, like this: ViewPager viewPager = findViewById(R.id.view_pager);

Understanding

The ViewPager used in this project is the default Android ViewPager and it is kept effectively the same as before. Only some of the values are extracted as instance variables so that they can be changed through reflection.

For example, in the onInterceptTouchEvent method, the instance variable minYXRatioForIntercept has been added to the ViewPager file so that it can be easily modified through reflection.

minYXRatioForIntercept can be modified to change the minimum swipe distance required to move the page up or down.

Similarly, in the onTouchEvent method, the instance variable minYXRatioForTouch has been added to the ViewPager file so that it can be easily modified through reflection.

In the VerticalViewPager file in this project, we swap the values of x and y in the onInterceptTouchEvent and onTouchEvent methods, and edit the required values through reflection in the init method.

Contributors

Deepak Mishra

Denver Braganza

verticalviewpager's People

Contributors

devenom1 avatar deepakmishra avatar

Watchers

James Cloos avatar  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.