Giter VIP home page Giter VIP logo

coolviewpager's Introduction

About

CoolViewPager is a custom ViewPager,it contains these follow features:

  1. support horizontal scrolling and vertical scrolling
  2. support automatic scrolling
  3. support setting auto-scrolling direction,auto-scrolling duration,auto-scrolling interval time
  4. support executing notifyDataSetChanged to refresh views immediately
  5. support setting the color of EdgeEffect
  6. contains appropriate PageTransformer for vertical scrolling

Screen Record

horizontal and vertical scrolling direction,duration and interval time for auto-scrolling
executing notifyDataSetChanged to refresh views immediately setting the color of EdgeEffect
contains appropriate PageTransformer for vertical scrolling

Apk

demo.apk

Usage

1 Add the dependency to your build.gradle

JitPack:
  • Add it in your root build.gradle at the end of repositories:
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
  • Add the dependency in your module build.gradle
dependencies {
        implementation 'com.github.HuanHaiLiuXin:CoolViewPager:v1.0.0'
}
Bintray:

Add the dependency in your module build.gradle

dependencies {
    implementation 'com.huanhailiuxin.view:coolviewpager:1.0.0'
}

2 Include the CoolViewPager widget in your layout

<com.huanhailiuxin.coolviewpager.CoolViewPager
    android:id="@+id/vp"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    />

3 Gain the CoolViewPager isntance in your Java code,set it's attributes and PagerAdapter

public class ActivityEdgeEffectColor extends BaseActivity {
    private CoolViewPager vp;
    
    ****
    CoolViewPager vp = findViewById(R.id.vp);
    vp.setScrollMode(CoolViewPager.ScrollMode.HORIZONTAL);
    vp.setAdapter(adapter);
    ****
}

We can set the attributes for a CoolViewPager instance via xml or via Java code.

attribute name description
cvp_scrollmode horizontal or vertical
cvp_autoscroll true or false: Set whether to open auto-scrolling
cvp_intervalinmillis auto-scrolling interval time in miliseconds
cvp_autoscrolldirection auto-scrolling direction: forward or backward
cvp_infiniteloop true or false: Set whether to open loop-scrolling
cvp_scrollduration auto-scrolling consume time in miliseconds
cvp_drawedgeeffect true or false: Set whether to draw edgeeffect
cvp_edgeeffectcolor setting the color of EdgeEffect

Via XML

<com.huanhailiuxin.coolviewpager.CoolViewPager
    android:id="@+id/vp"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:cvp_scrollmode="vertical"
    app:cvp_autoscroll="true"
    app:cvp_intervalinmillis="1000"
    app:cvp_autoscrolldirection="backward"
    app:cvp_infiniteloop="true"
    app:cvp_scrollduration="600"
    app:cvp_drawedgeeffect="true"
    app:cvp_edgeeffectcolor="@color/colorPrimary"
    />

Via Java code

public class ActivityEdgeEffectColor extends BaseActivity {
    private CoolViewPager vp;
    
    private void initViewPager(){
        vp = findViewById(R.id.vp);
        vp.setScrollMode(CoolViewPager.ScrollMode.VERTICAL);
        vp.setAutoScroll(true,1000);
        vp.setAutoScrollDirection(CoolViewPager.AutoScrollDirection.BACKWARD);
        vp.setInfiniteLoop(true);
        vp.setScrollDuration(true,600);
        vp.setDrawEdgeEffect(true);
        vp.setEdgeEffectColor(getResources().getColor(R.color.colorPrimary));
    }
}

Author

License

Copyright 2018 HuanHaiLiuXin

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.

coolviewpager's People

Contributors

huanhailiuxin 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.