Banner 无限轮播

版权声明:本文为博主原创文章,转载请注明出处。 https://blog.csdn.net/qq_41673194/article/details/80520840
依赖:
//banner
    implementation 'com.youth.banner:banner:1.4.9'
    implementation 'com.github.bumptech.glide:glide:3.7.0'
控件使用:
<com.youth.banner.Banner
    android:id="@+id/banner"
    android:layout_width="match_parent"
    android:layout_height="300dp"/>
Java代码(banner为控件):
List<String> li = new ArrayList<>();
li.add("https://www.zhaoapi.cn/images/quarter/ad1.png");
li.add("https://www.zhaoapi.cn/images/quarter/ad2.png");
li.add("https://www.zhaoapi.cn/images/quarter/ad3.png");
li.add("https://www.zhaoapi.cn/images/quarter/ad4.png");
banner.setImageLoader(new ImageLoader() {
    @Override
    public void displayImage(Context context, Object path, ImageView imageView) {
       Glide.with(context).load(path).into(imageView);
    }
});
banner.setImages(li);
banner.start();

猜你喜欢

转载自blog.csdn.net/qq_41673194/article/details/80520840