//导入依赖
compile 'com.xhb:xbanner:1.2.9'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'jp.wasabeef:glide-transformations:1.0.6'
//布局
<com.stx.xhb.xbanner.XBanner
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/shouyeXBanner"
android:layout_width="match_parent"
android:layout_height="180dp"
app:pointsPosition="CENTER"
app:AutoPlayTime="3000"
app:pointsContainerBackground="#44aaaaaa"/>
//获取id
shouyeXBanner = itemView.findViewById(R.id.shouyeXBanner);
//设置数据源
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");
shouyeXBanner.setData(imagesurl,null);//设置装载数据源
shouyeXBanner.setPoinstPosition(XBanner.CENTER);//设置指示器的显示位置
shouyeXBanner.setmAdapter(new XBanner.XBannerAdapter() {//xbanner的适配器,加载图片
@Override
public void loadBanner(XBanner banner, Object model, View view, int position) {
ImageLoader.getInstance().displayImage(imagesurl.get(position), (ImageView) view, ImageLoaderUtil.showImag());
}
});
//常用属性
自定义属性说明
属性名 属性说明 属性值
isAutoPlay 是否支持自动轮播 boolean类型,默认为true
AutoPlayTime 图片轮播时间间隔 int值,默认为5s
pointNormal 指示器未选中时状态点 drawable,不设置的话为默认状态点
pointSelect 指示器选中时状态点 drawable,不设置的话为默认状态点
pointsVisibility 是否显示指示器 boolean类型,默认为true
pointsPosition 指示点显示位置 LEFT、CENTER、RIGHT类型,默认为CENTER
pointsContainerBackground 指示器背景 可自定义设置指示器背景
pointContainerPosition 指示器显示位置 TOP、BOTTOM类型,默认为BOTTOM
pointContainerLeftRightPadding 指示点容器左右内间距 dimension,默认为10dp
pointTopBottomPadding 指示点上下内间距 dimension,默认为6dp
pointLeftRightPadding 指示点左右内间距 dimension,默认为3dp
tipTextColor 提示文案的文字颜色 reference color,默认为white
tipTextSize 提示文案的文字大小 dimension,默认为10dp
xbanner使用
最新推荐文章于 2022-08-11 14:41:58 发布