In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "Android ViewPager how to achieve infinite round robin ad bit Banner effect". In daily operation, I believe many people have doubts about how to achieve infinite round robin ad bit Banner effect in Android ViewPager. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for everyone to answer the doubt that "Android ViewPager how to achieve infinite round robin ad bit Banner effect"! Next, please follow the editor to study!
Now some app usually put an ad space in the head and a small circle indicator at the bottom to indicate the current page number of the ad space, and the rotation shows some pictures from the Internet. This ad bit banner is a typical android ViewPager implementation, but if you implement such a ViewPager yourself, you have to solve a series of trivial problems, such as:
(1) this ad space ViewPager should support unlimited rotation. For example, there are three pictures, A _ Magi B ~ C, when the user slides to the last C and then to A, and vice versa.
(2) ViewPager needs to achieve automatic playback, such as switching to the next picture for a few seconds, such as 2 seconds.
(3) usually a small circle of indicators is placed under such a ViewPager to vividly indicate the current page number.
This kind of Android advertising space has a high degree of reuse and high universal length. There is an open source project on Github: https://github.com/youth6201314/banner
All the above functions are realized, and a variety of style choices are provided. It is also easy to use, such as writing a simple example, xml code (snippet):
Referenced selected_radius.xml:
Unselected_radius.xml:
The color value # 80ffffff is white translucent.
Upper Java code:
Banner banner= (Banner) view.findViewById (R.id.banner); String url1= "http://xxx.xxx.xxx.jpg"; String url2=" http://xxx.xxx.xxx.jpg"; String url3= "http://xxx.xxx.xxx.jpg"; String [] images= new String [] {url1,url2,url3}; banner.setBannerStyle (BannerConfig.CIRCLE_INDICATOR); banner.setImages (images); banner.setDelayTime (2000)
The result of running the code:
At this point, the study on "how to achieve the Banner effect of ad bits in infinite rotation by Android ViewPager" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.