当前位置:网站首页>Use the open source project [banner] to achieve the effect of rotating pictures (with dots)
Use the open source project [banner] to achieve the effect of rotating pictures (with dots)
2022-07-02 02:22:00 【Rannki】
banner Open source project address :GitHub - youth5201314/banner: Banner 2.0 coming !Android Advertising image rotation control , Internally based on ViewPager2 Realization ,Indicator and UI You can customize .
Add network access :
<uses-permission android:name="android.permission.INTERNET" />
stay 【Android Manifest.xml】 Medium 【application】 Join in 【android:usesCleartextTraffic="true"】 Use clear text network request , Otherwise, you have to http Access changed to https visit .API Level 28 Or higher level applications default to “ false”,false Identify the meaning of refusing applications to use plaintext network requests .
Add dependency :
implementation 'io.github.youth5201314:banner:2.2.2' // banner rely on implementation 'com.github.bumptech.glide:glide:4.12.0' //glide Load network image dependency
Add... To the layout file :
<com.youth.banner.Banner android:id="@+id/banner" android:layout_width="match_parent" android:layout_height="300dp" app:layout_constraintBottom_toTopOf="@+id/btn" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"/>
MainActivity Add :
List<String> bannerList = new ArrayList<>(); bannerList.add("http://ww4.sinaimg.cn/large/006uZZy8jw1faic21363tj30ci08ct96.jpg"); bannerList.add("http://ww4.sinaimg.cn/large/006uZZy8jw1faic259ohaj30ci08c74r.jpg"); bannerList.add("http://ww4.sinaimg.cn/large/006uZZy8jw1faic2b16zuj30ci08cwf4.jpg"); bannerList.add("http://ww4.sinaimg.cn/large/006uZZy8jw1faic2e7vsaj30ci08cglz.jpg"); Banner banner = findViewById(R.id.banner); banner.setAdapter(new BannerImageAdapter<String>(bannerList) { @Override public void onBindView(BannerImageHolder holder, String data, int position, int size) { Glide.with(holder.itemView) .load(data) .apply(RequestOptions.bitmapTransform(new RoundedCorners(30))) .into(holder.imageView); } }).addBannerLifecycleObserver(this).setBannerRound(30).setIndicator(new CircleIndicator(this));
Open the app to see , The carousel map is realized , It also comes with small dots .
边栏推荐
- What is the function of the headphone driver
- Query word weight, search word weight calculation
- leetcode2310. The one digit number is the sum of integers of K (medium, weekly)
- Infix expression to suffix expression (computer) code
- Opengauss database backup and recovery guide
- Oracle creates a user with read-only permission in four simple steps
- WebGPU(一):基本概念
- trading
- 2022 safety officer-c certificate examination questions and mock examination
- How to turn off the LED light of Rog motherboard
猜你喜欢
[liuyubobobo play with leetcode algorithm interview] [00] Course Overview
【liuyubobobo-玩转Leetcode算法面试】【00】课程概述
How to build and use redis environment
What are the necessary things for students to start school? Ranking list of Bluetooth headsets with good sound quality
[learn C and fly] 1day Chapter 2 (exercise 2.2 find the temperature of Fahrenheit corresponding to 100 ° f)
WebGPU(一):基本概念
Opencascade7.6 compilation
How to turn off the LED light of Rog motherboard
Software No.1
【带你学c带你飞】1day 第2章 (练习2.2 求华氏温度 100°F 对应的摄氏温度
随机推荐
How to execute an SQL in MySQL
超图iServer rest服务之feature查询
How to solve MySQL master-slave delay problem
leetcode373. 查找和最小的 K 对数字(中等)
大厂裁员潮不断,双非本科出身的我却逆风翻盘挺进阿里
es面試題
[punch in questions] integrated daily 5-question sharing (phase II)
Word search applet design report based on cloud development +ppt+ project source code + demonstration video
AR增强现实可应用的场景
[C #] use regular verification content
Flutter un élément au milieu, l'élément le plus à droite
Pat a-1165 block reversing (25 points)
Quality means doing it right when no one is looking
Regular expression learning notes
【带你学c带你飞】2day 第8章 指针(练习8.1 密码开锁)
Logging only errors to the console Set system property ‘log4j2. debug‘ to sh
leetcode2309. 兼具大小写的最好英文字母(简单,周赛)
使用开源项目【Banner】实现轮播图效果(带小圆点)
How to build and use redis environment
As a software testing engineer, will you choose the bank post? Laolao bank test post