[中文版](README_CN.md) | **English** </br>
XBanner
=========
This is a banner suppoted gifs and images.无限轮播的广告控件,提供gif支持。
## Introduction
A banner for showing Ads with the Viewpager and supports automatic play in an infinite loop.With XBanner you can customize the style of this banner.XBanner also provides gif supprot,and we use the 3rd party dependency to load gifs for better perfoemance.
## Effects
#### The final effect is as the gif below.
<div align=center><img width="316" height="584" src="https://github.com/AbbyJM/XBanner/raw/master/gif/demo1.gif"/></div>
#### Customize your banner style now.
<a href="gif/demo2.gif"><img src="gif/demo2.gif" width="30%"/></a> <a href="gif/demo3.gif"><img src="gif/demo3.gif" width="30%"/></a> <a href="gif/demo4.gif"><img src="gif/demo4.gif" width="30%"/></a>
## Gradle
```java
dependencies{
compile 'com.abby.app:xbanner:1.5.5' //the latest version
//Thans koral-- for android-gif-drawable,it's a good solution for showing gif images.It is high performance.
//Instead of using ImageView+Glide,we use gif-drawable for better performance
//The dependency 'pl.droidsonroids.gif:android-gif-drawable:1.2.8' was added in this project.
}
```
## Usage
#### A simple way to use XBanner is like below. releaseBanner() must be called when the view is destroying
```java
@Override
public void onCreate(Bundle savedInstanceState) {
int[] res={R.drawable.pic1,R.drawable.pic2,R.drawable.pic3,R.drawable.pic4,R.drawable.pic5};
xbanner.isAutoPlay(false)
.setDelay(3000)
.setImageRes(res)
.start();
}
@Override
public void onDestroy(){
super.onDestroy();
xbanner.releaseBanner(); // releaseBanner() must be called when the view is destroying
}
```
#### A simple way to use XBanner with titles.***BannerType must be set to TITLE_TYPES when using titles.***
```java
@Override
public void onCreate(Bundle savedInstanceState) {
int[] res={R.drawable.pic1,R.drawable.pic2,R.drawable.pic3,R.drawable.pic4,R.drawable.pic5};
List<String> titles=Arrays.asList("This is the picture 1","This is the picture 2","This is the picture 3","This is the picture 4","This is the picture 5");
xbanner.isAutoPlay(false)
.setBannerTypes(XBanner.NUM_INDICATOR_TITLE)//must set banner type to title type to avoid some logic error
.setDelay(3000)
.setImageRes(res)
.setTitles(titles)// setImageResAndTitles(res,titles) also OK
.start();
}
@Override
public void onDestroy(){
super.onDestroy();
xbanner.releaseBanner();// releaseBanner() must be called when the view is destroying
}
```
#### If you want to load images from the url,an ImageLoader will be needed.A simple way to use ImageLoader is like below.
```java
@Override
public void onCreate(Bundle savedInstanceState) {
List<String> imageUrls=new ArrayList<>();
imageUrls.add("http://img2.tgbusdata.cn/v2/thumb/jpg/YzQ0NSw4MzAsNjQwLDQsMywxLC0xLDAscms1MA==/u/olpic.tgbusdata.cn/uploads/allimg/160324/238-160324160031.jpg");
imageUrls.add("http://img2.tgbusdata.cn/v2/thumb/jpg/ZjliZCw4MzAsNjQwLDQsMywxLC0xLDAscms1MA==/u/olpic.tgbusdata.cn/uploads/allimg/160324/238-160324160031-50.jpg");
xbanner.isAutoPlay(false)
.setDelay(3000)
.setImageUrls(imageUrls)
//.asGif() if you want to load gif,call it
.setImageLoader(new AbstractUrlLoader() {
@Override
/**
*the one using Glide,you can customize your ImageLoader
*when loading gifs,a default ImageLoader will be applied,which you don't need to add one
*but if you want to customize your loader,do it
*/
public void loadImages(Context context, String url, ImageView image) {
Glide.with(context)
.load(url)
.into(image);
}
@Override
public void loadGifs(String url, GifImageView gifImageView, ImageView.ScaleType scaleType) {
}
}).start();
}
@Override
public void onDestroy(){
super.onDestroy();
xbanner.releaseBanner();// releaseBanner() must be called when the view is destroying
}
```
### A simple way to load gifs
```java
@Override
public void onCreate(Bundle savedInstanceState) {
banner.setImageUrls(gifUrls)
.asGif()
.setLoadingProgressType(XBanner.CIRCLE_PROGRESS) //now you can apply a loading progress view here
.start();
}
@Override
public void onDestroy(){
super.onDestroy();
xbanner.releaseBanner();// releaseBanner() must be called when the view is destroying
}
```
## Feature(Methods)
|name|description|params
|----|-----|----|
|setBannerTypes|set the type of banner,CIRCLEINDICATOR by default|CIRCLE_INDICATOR,***CIRCLE_INDICATOR_TITLE***,CUBE_INDICATOR,***NUM_INDICATOR,NUM_INDICATOR_TITLE***|
|setIndicatorGravity|set the gravity of indicators,___CENTER by default___|INDICATOR_START,***INDICATOR_CENTER***,INDICATOR_END|
|setUpIndicatorSize|set up the size of indicators,***IN PX,BOTH SELECTED AND UNSELECTED will be set***|int indicatorSize|
|setUpIndicators|set up the indicator resID|int res_selected,int res_unselected|
|setEllipsizeType|set the ellipsizetype of the title text,,___END by default___|ELLIPSIZE_END,***ELLIPSIZE_MARQUEE***|
|setImageScaleType|set the scale type of the image,___this method must be called before setting up the images___,___FIT_XY by default___|ImageView.ScaleType scaleType|
|setScroller|set the scroller of the viewpager|the scroller to be applied
|setTitlebgAlpha|set the title background to be alpha|no params|
|setImageRes|set the image resource|int[] res|
|setImageUrls|set the image urls|List< String > urls|
|setTitles|set the titles|List< String > titles|
|setImageResAndTitles|set the imageres and titles|int[] res,List< String > titles|
|setImageUrlsAndTitles|set the image urls and titles|List< String > urls,List< String > titles|
|setPageTransformer|set the transformer for the viewpager|PageTransformer transformer|
|setDelay|set the interval of the banner when playing,***IN MS***|int delay|
|isAutoPlay|indicate if the banner is automatically playing|boolean is autoPlay|
|setTransformerSpeed|set the transform speed when idle,***IN MS***|int speed|
|setTitleHeight|set the height of title,***IN PX***|int height|
|setBannerPageListener|set the banner listener|BannerPageListener listener|
|getViewPager|get the viewPager of the banner|no params|
|asGif|indicate the urls are gif urls|no params|
|clearGifCache|clear the cache of gifs|no params|
|autoDeleteGifCache|automatically delete the cache of gifs when reach the the given size|int sizeInMB|
|start|start the banner,***must be set to start the banner***|no params|
|setLoadingProgressType|set a progress view when loading gifs|CIRCLE_PROGRESS or TEXT_PROGRESS|
|notifyDataSetChanged|refresh data after recalling setImageUrls and setImageRes|no params|
## Notice
* []() if the images do not display,check out your network permission and your image if they are configured correctly
* []() must set the banner type to TITLE TYPE when we set titles to avoid some logic errors
* []() setImageScaleType must be called before we set the images
* []() set an ImageLoader when loading images from url,but if you are loading gifs,you don't really have to
* []() must call asGif() after you set the Url with setImageUrls method when loading gif,no need to set an ImageLoader if so
* []() must call releaseBanner() in onDestroy()
* []() to get a better visaul effect,indicator gravity is set to END when in TITLE mode
* []() just confirm that your gif is in a correct format when you are downloading gif,or it won't be displayed
* []() when refreshing data at run time,you should call notifyDataSetChanged() and you should reconfig the bannerPageListener because the listener is base on the position not the image itself,***only image
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
XBanner-master.zip (86个子文件)
XBanner-master
gradlew 5KB
settings.gradle 33B
gif
demo2.gif 3.84MB
demo5.gif 558KB
demo4.gif 4.04MB
demo3.gif 5.31MB
demo1.gif 23.15MB
.idea
runConfigurations.xml 564B
misc.xml 2KB
compiler.xml 686B
gradle.xml 679B
smartfox_info.xml 188B
inspectionProfiles
Project_Default.xml 7KB
profiles_settings.xml 235B
modules.xml 472B
copyright
profiles_settings.xml 74B
README_CN.md 9KB
gradle
wrapper
gradle-wrapper.properties 230B
gradle-wrapper.jar 52KB
README.md 9KB
gradlew.bat 2KB
gradle.properties 730B
xbanner
src
androidTest
java
com
app
abby
xbanner
ExampleInstrumentedTest.java 744B
test
java
com
app
abby
xbanner
ExampleUnitTest.java 398B
main
AndroidManifest.xml 473B
res
mipmap-xhdpi
ic_launcher.png 5KB
ic_launcher_round.png 6KB
drawable
indicator_unselected.xml 225B
indicator_bg.xml 190B
indicator_cube_selected.xml 195B
indicator_selected.xml 224B
indicator_cube_unselected.xml 195B
layout
xbanner.xml 697B
values
colors.xml 386B
values.xml 2KB
strings.xml 70B
styles.xml 383B
mipmap-xxhdpi
ic_launcher.png 8KB
ic_launcher_round.png 10KB
java
com
app
abby
xbanner
GifDownloader.java 13KB
XBanner.java 34KB
ImageLoader.java 403B
GifDownloadManager.java 464B
XBPagerAdapter 3KB
XBannerScroller.java 971B
GifImageLoader.java 561B
XBannerViewPager.java 416B
AbstractUrlLoader.java 306B
RingProgressBar.java 8KB
FileSizeUtil.java 3KB
.gitignore 7B
build.gradle 3KB
proguard-rules.pro 916B
.gitignore 118B
app
src
androidTest
java
com
app
abby
xbannerdemo
ExampleInstrumentedTest.java 752B
test
java
com
app
abby
xbannerdemo
ExampleUnitTest.java 402B
main
AndroidManifest.xml 1KB
res
mipmap-hdpi
ic_launcher.png 3KB
ic_launcher_round.png 4KB
mipmap-xxxhdpi
ic_launcher.png 10KB
ic_launcher_round.png 14KB
mipmap-xhdpi
ic_launcher.png 5KB
ic_launcher_round.png 6KB
mipmap-mdpi
ic_launcher.png 2KB
ic_launcher_round.png 2KB
drawable
ic_selected.xml 223B
ic_unselected.xml 225B
ic_star_black_24dp.xml 376B
ic_sentiment_neutral_black_24dp.xml 774B
ic_sentiment_satisfied_black_24dp.xml 811B
layout
activity_main.xml 1KB
drawable-xxhdpi
pic3.jpg 111KB
pic1.jpg 96KB
pic2.jpg 107KB
pic5.jpg 107KB
pic4.jpg 102KB
values
colors.xml 208B
strings.xml 74B
styles.xml 383B
mipmap-xxhdpi
ic_launcher.png 8KB
ic_launcher_round.png 10KB
java
com
app
abby
xbannerdemo
MainActivity.java 6KB
.gitignore 7B
build.gradle 1KB
proguard-rules.pro 916B
build.gradle 641B
共 86 条
- 1
资源评论
菜根小姜
- 粉丝: 1
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功