依赖:
compile 'com.youth.banner:banner:1.4.10' //最新版本
布局:
<com.youth.banner.Banner
android:id="@+id/banner"
android:layout_width="match_parent"
android:layout_height="200dp" />
主页面:
//展示图片的类
public class ImgApp extends ImageLoader{
@Override
public void displayImage(Context context, Object path, ImageView imageView) {
Glide.with(context).load(path).into(imageView);
}
}
private void getPic() {
List<AllBean.RetBean.ListBean.ChildListBean> childList = list.get(0).getChildList();
for (int i = 0; i <childList.size() ; i++) {
listimg.add(childList.get(i).getPic());
}
banner.setImages(listimg).setImageLoader(new ImgApp())
.setBannerAnimation(AccordionTransformer.class)
.isAutoPlay(true)
.setDelayTime(2000)
.start();
}