简介:功能强大的图片无限自动轮播控件,可支持自定义状态点及指示器显示位置等功能
支持图片无限轮播的控件,可进行自定义功能。
dependencies {
compile 'com.xhb:xbanner:1.0.0'
}
<com.stx.xhb.xbanner.XBanner
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/banner_1"
android:layout_width="match_parent"
android:layout_height="180dp"
app:pointsPosition="CENTER"
app:AutoPlayTime="3000"
app:pointsContainerBackground="#44aaaaaa"
app:pointNormal="@drawable/shape_noraml"
app:pointSelect="@drawable/shape_selected"/>
初始化:直接传入视图集合进行初始化
imgesUrl = new ArrayList<>();
imgesUrl.add("http://img3.fengniao.com/forum/attachpics/913/114/36502745.jpg");
imgesUrl.add("http://imageprocess.yitos.net/images/public/20160910/99381473502384338.jpg");
imgesUrl.add("http://imageprocess.yitos.net/images/public/20160910/77991473496077677.jpg");
imgesUrl.add("http://imageprocess.yitos.net/images/public/20160906/1291473163104906.jpg");
mBannerNet.setData(imgesUrl);
可根据自己项目需要使用相应的图片加载工具进行加载图片,此处使用 Glide,进行加载,可配置占位图等
mBannerNet.setmAdapter(this);
@Override
public void loadBanner(XBanner banner, View view, int position) {
Glide.with(this).load(imgesUrl.get(position)).into((ImageView) view);
}
mBannerNet.setOnItemClickListener(new XBanner.OnItemClickListener() {
@Override
public void onItemClick(XBanner banner, int position) {
Toast.makeText(MainActivity.this, "点击了第"+position+"图片", Toast.LENGTH_SHORT).show();
}
});
属性名 | 属性说明 | 属性值 |
---|---|---|
isAutoPlay | 是否支持自动轮播 | boolean 类型,默认为 true |
AutoPlayTime | 图片轮播时间间隔 | int 值,默认为 5s |
pointNormal | 指示器未选中时状态点 | drawable,不设置的话为默认状态点 |
pointSelect | 指示器选中时状态点 | drawable,不设置的话为默认状态点 |
pointsVisibility | 是否显示指示器 | boolean 类型,默认为 true |
pointsPosition | 指示点显示位置 | LEFT、CENTER、RIGHT 类型,默认为 CENTER |
pointsContainerBackground | 指示器背景 | 可自定义设置指示器背景 |
个人邮箱:[email protected]
GitHub 主页
简书主页
个人博客
Copyright (C) 2016 [email protected]
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.