• Stars
    star
    913
  • Rank 50,033 (Top 1.0 %)
  • Language
    Java
  • Created over 9 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A ViewPager can auto play and loop

RollViewPager

A Viewpager can auto-play.

中文 | English

The touch will pause playback, continue to play until a delay period after the end of the touch.
looks like this,Indicator can be customized to point or number, the gravity can be changed also.
example

Depandence

compile 'com.jude:rollviewpager:1.4.6'

Usage

<com.jude.rollviewpager.RollPagerView
    android:layout_width="match_parent"
    android:layout_height="180dp"
    app:rollviewpager_play_delay="3000"/>

app:rollviewpager_play_delay="3000" period,unit is ms。0 for no auto-play。default is 0.
app:rollviewpager_hint_gravity="center" graviengty. left,center,right。default is center.
app:rollviewpager_hint_color="#7c7c7c" color for indicator's container.default is black.
app:rollviewpager_hint_alpha="80" alpha for indicator's container。0 for complete transparent,255 for no transparent。default is 0.
app:rollviewpager_hint_paddingLeft="16dp" padding for indicator's container
app:rollviewpager_hint_paddingRight="16dp"
app:rollviewpager_hint_paddingTop="16dp"
app:rollviewpager_hint_paddingBottom="16dp"

Generally just need set the play_delay.

##HintView provide Hintview to DIY the indicator; setHintView(HintView hintview)

  • HintView
    • ShapeHintView
      • IconHintView
      • ColorPointHintView
    • TextHintView

For example:

mRollViewPager.setHintView(new IconHintView(this,R.drawable.point_focus,R.drawable.point_normal));
mRollViewPager.setHintView(new ColorPointHintView(this, Color.YELLOW,Color.WHITE));
mRollViewPager.setHintView(new TextHintView(this));
mRollViewPager.setHintView(null);//hide the indicator

##ItemClickListener

mRollViewPager.setOnItemClickListener(new OnItemClickListener() {
  @Override
  public void onItemClick(int position) {
      Toast.makeText(MainActivity.this,"Item "+position+" clicked",Toast.LENGTH_SHORT).show();
  }
});

##Adapter There offer two Adapter for use conveniently.the RollViewPager can also user other PagerAdapter.

####StaticPagerAdapter this Adapter will store the every page(View), Once create multiple use.may take up more memory. Like FragmentPagerAdapter.this can use for any ViewPager;

####DynamicPagerAdapter this Adapter will not store the View.it create new View every time.save the memory. Like FragmentStatePagerAdapter.this can use for any ViewPager;

//the usage of the 2 adapter is same;
mRollViewPager.setAdapter(new TestNomalAdapter());
private class TestNomalAdapter extends StaticPagerAdapter{
    private int[] imgs = {
            R.drawable.img1,
            R.drawable.img2,
            R.drawable.img3,
            R.drawable.img4,
    };

    @Override
    public View getView(ViewGroup container, int position) {
        ImageView view = new ImageView(container.getContext());
        view.setImageResource(imgs[position]);
        view.setScaleType(ImageView.ScaleType.CENTER_CROP);
        view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        return view;
    }
    
    @Override
    public int getCount() {
        return imgs.length;
    }
}

####LoopPagerAdapter A loop adapter.realize by return MAX_INT in getCount(). same as StaticPagerAdapter in page store.Once create multiple use. this adapter only for RollViewPager. the usage is very simple。

mRollViewPager.setAdapter(new TestLoopAdapter(mRollViewPager));
private class TestLoopAdapter extends LoopPagerAdapter{
    private int[] imgs = {
            R.drawable.img1,
            R.drawable.img2,
            R.drawable.img3,
            R.drawable.img4,
    };
    
    public TestLoopAdapter(RollPagerView viewPager) {
        super(viewPager);
    }
    
    @Override
    public View getView(ViewGroup container, int position) {
        ImageView view = new ImageView(container.getContext());
        view.setImageResource(imgs[position]);
        view.setScaleType(ImageView.ScaleType.CENTER_CROP);
        view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        return view;
    }
    
    @Override
    public int getRealCount() {
        return imgs.length;
    }
}

Play Control

rollViewPager.pause()
rollViewPager.resume()
rollViewPager.isPlaying()

License

Copyright 2015 Jude

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.

More Repositories

1

EasyRecyclerView

ArrayAdapter,pull to refresh,auto load more,Header/Footer,EmptyView,ProgressView,ErrorView
Java
2,028
star
2

SwipeBackHelper

make your activity can swipe to close
Java
1,382
star
3

Beam

MVP开发框架
Java
617
star
4

Utils

android 各种工具库
Java
287
star
5

Joy

豆逼APP源码
Java
122
star
6

FitSystemWindowLayout

适应Statusbar与NavigationBar的各种Layout
Java
119
star
7

RequestVolley

基于Volley的便捷网络请求库
Java
91
star
8

JCenter

上传Jcenter的gradle配置
60
star
9

Fishing

空钩 APP
Java
57
star
10

Ferryman

Android页面路由跳转框架
Java
42
star
11

SMSSDK

一个可以便捷使用短信验证的库
Java
31
star
12

Know

问答社区APP。新技术Demo向。
Java
30
star
13

Interceptor

Java
21
star
14

ImageProvider

图片提供者,从系统,相册,网络提供图片。
Java
17
star
15

ExGridView

可动态添加高度适应的GridView
Java
16
star
16

FloatActionView

基于Adapter的Float Action Button.仿Evernote
Java
13
star
17

TAGView

colorful tag with icon
Java
12
star
18

GeassClient

Android Root开发支持库
Java
11
star
19

KeyChain

PasswordBox APP
Java
11
star
20

ActivitySlider

activity跟随手势滑动关闭
Java
11
star
21

EmotionShow

外包!!!
Java
10
star
22

lifeline

Java
9
star
23

LifeGame

生命游戏Android版
Java
9
star
24

know_web

逼乎web端
PHP
8
star
25

JobGod2

诚客兼职APP
Java
8
star
26

2016WinterHomeWork

红岩移动Android2016寒假作业
6
star
27

Jarvis

Java
5
star
28

Texas

华为杯智能大赛德克萨斯扑克AI
Java
4
star
29

AndroidFrameWork

Android部分机制原理的简单模型
Java
4
star
30

Automobile

上云配
Java
3
star
31

SBReader

String Buffer Analysis Tool
Java
3
star
32

LBSChat

地图社交demo
Java
3
star
33

Jude95.github.io

CSS
3
star
34

EasyCrypto

Crypto tool for java
Java
3
star
35

Happiness

半个外包只是一部分界面
Java
2
star
36

FunctionGraph

逗B的控制台版函数图像显示器
Java
2
star
37

Album

Java
1
star
38

rollup-plugin-workbox-build

Rollup plugin to apply workbox-build
JavaScript
1
star