☺无限轮播ViewPagerLayout 广告栏 banner 多种滑动的样式 使用API简单明了
Step 1. Add the JitPack repository to your build file
dependencies {
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
}
Step 2. Add the dependency
dependencies {
compile 'com.github.why168:LoopViewPagerLayout:2.1.8'
}
#LoopViewPagerLayout
-dontwarn com.github.why168
-keep class com.github.why168
https://jitpack.io/com/github/why168/LoopViewPagerLayout/v2.1.0/javadoc/
<?xml version="1.0" encoding="utf-8"?>
<com.github.why168.LoopViewPagerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mLoopViewPagerLayout"
android:layout_width="match_parent"
android:layout_height="200dp" />
mLoopViewPagerLayout = (LoopViewPagerLayout)findViewById(R.id.mLoopViewPagerLayout);
mLoopViewPagerLayout.setLoop_ms(2000);//轮播的速度(毫秒)
mLoopViewPagerLayout.setLoop_duration(1000);//滑动的速率(毫秒)
mLoopViewPagerLayout.setLoop_style(LoopStyle.Empty);//轮播的样式-默认empty
mLoopViewPagerLayout.setIndicatorLocation(IndicatorLocation.Center);//指示器位置-中Center
mLoopViewPagerLayout.setNormalBackground(R.drawable.normal_background);//默认指示器颜色
mLoopViewPagerLayout.setSelectedBackground(R.drawable.selected_background);//选中指示器颜色
mLoopViewPagerLayout.initializeData(mActivity);//初始化数据
ArrayList<BannerInfo> bannerInfos = new ArrayList<>();
bannerInfos.add(new BannerInfo<Integer>(R.mipmap.a, "第一张图片"));
bannerInfos.add(new BannerInfo<String>("url", "第二张图片"));
bannerInfos.add(new BannerInfo<Integer>(R.mipmap.b, "第三张图片"));
bannerInfos.add(new BannerInfo<Integer>(R.mipmap.c, "第四张图片"));
bannerInfos.add(new BannerInfo<Integer>(R.mipmap.d, "第五张图片"));
mLoopViewPagerLayout.setOnLoadImageViewListener(new OnDefaultImageViewLoader());//设置图片加载&自定义图片监听
mLoopViewPagerLayout.setOnBannerItemClickListener(this);//设置监听
mLoopViewPagerLayout.setLoopData(bannerInfos);//设置数据
/**
* Load ImageView Listener
*
* @author Edwin.Wu
* @version 2016/12/6 14:40
* @since JDK11
*/
public interface OnLoadImageViewListener {
/**
* create image
*
* @param context context
* @return image
*/
ImageView createImageView(Context context);
/**
* image load
*
* @param imageView ImageView
* @param parameter String 可以为一个文件路径、uri或者url
* Uri uri类型
* File 文件
* Integer 资源Id,R.drawable.xxx或者R.mipmap.xxx
* byte[] 类型
* T 自定义类型
*/
void onLoadImageView(ImageView imageView, Object parameter);
}
/**
* Banner Click
*
* @author Edwin.Wu
* @version 2016/12/6 15:38
* @since JDK11
*/
public interface OnBannerItemClickListener {
/**
* banner click
*
* @param index subscript
* @param banner bean
*/
void onBannerClick(int index, ArrayList<BannerInfo> banner);
}
2016/06/12
2016/06/15
2016/07/01
2016/11/08 00:25
2016/11/08 11:12
2016/11/28 19:20
2016/12/01 00:08
2016/12/01 13:18
2016/12/01 18:18
2016/12/05 18:20
2016/12/07 17:38
2016/12/12 12:03
2017/4/11 17:10
2017/4/16 17:05
2017/6/16
2018/2/27
欢迎加入Android技术交流大群,群号码:554610222
Android技术交流,进群后请改名片.
例如:北京-李四.
群内交流以技术为主,乱发黄图乱发广告乱开车者一律踢.
Copyright (c) 2016 Edwin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.