README 中文版
About
CoolViewPager is a custom ViewPager,it contains these follow features:
- support horizontal scrolling and vertical scrolling
- support automatic scrolling
- support setting auto-scrolling direction,auto-scrolling duration,auto-scrolling interval time
- support executing notifyDataSetChanged to refresh views immediately
- support setting the color of EdgeEffect
- contains appropriate PageTransformer for vertical scrolling
Screen Record
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);
****
}
Attributes
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.