Banner 实现图片轮播
简介
导入
自定义样式
快捷使用
总结
Blog如有不对,敬请斧正
喜欢Android的可以关注我,日常更新Android干货
看都看到这了,加个关注叭!
简介
Banner能实现循环播放多个广告图片和手动滑动循环等功能,Banner框架可以进行不同样式、不同动画设置,以及完善的api方法能满足大部分软件首页轮播图效果的需求。
如:
QQ音乐:
网易云:
导入
implementation 'com.youth.banner:banner:2.1.0'
自定义样式
主要是为Banner组件,添加适配器,继承自 BannerAdapter,BannerAdapter又适配器继承自RecyclerView.Adapter,故用法和RecyclerView.Adapter一样
如果RecyclerView还了解的可以看我以前的博客
地址:https://blog.csdn.net/weixin_44758662/article/details/108942044
步骤1:
在XML加入Banner组件
activity_mian.xml:
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#372E2C2C"
>
android:id="@+id/banner"
android:layout_width="match_parent"
android:layout_height="110dp"
app:banner_radius="15dp"
android:layout_marginTop="15dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
app:banner_loop_time="20