Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/genius158/simplebanner
(最简单的广告轮播)the most simple banner
https://github.com/genius158/simplebanner
banner
Last synced: 3 months ago
JSON representation
(最简单的广告轮播)the most simple banner
- Host: GitHub
- URL: https://github.com/genius158/simplebanner
- Owner: genius158
- Created: 2016-12-19T05:19:00.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-08-23T01:34:58.000Z (about 7 years ago)
- Last Synced: 2024-06-16T06:34:05.018Z (5 months ago)
- Topics: banner
- Language: Java
- Homepage:
- Size: 584 KB
- Stars: 18
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-github-android-ui - simplebanner - 基于adapter的轮播图实现 (轮播图)
README
# simplebanner
![GIF](GIF.gif)
# 原理
在adapter原来的数据的最前面插入最后面的元素,最后面同理,与viewpager那种size设置成无限相比,这样做性能相对更好,更节省内存。而size无限,单它的当前项为一个较大的数值,内部计算也会相应的增加计算压力。
# gradle
# how to use
##```
banner.resumeScroll();//回复
banner.pauseScroll();//暂停
banner.setInterval(5000);
banner.setPageChangeDuration(500);
banner.setBannerDataInit(new Banner.BannerDataInit() {
@Override
public ImageView initImageView() {
//设置图片加载的控件(如:Fresco 这里可以传入SimpleDraweeView)
return (ImageView) getLayoutInflater().inflate(R.layout.imageview, null);
}@Override
public void initImgData(ImageView imageView, String imgPath) {
//可在这里控制图片的加载,
//ImageLoader.getInstance().displayImage(imgPath, imageView, options);
//((SimpleDraweeView)imageView).setImageURI(Uri.parse(imgPath));
}
});
banner.setDataSource(drawables);//----------------------indicator start------------------------------
bannerIndicator = (BannerIndicator) findViewById(R.id.indicator);
bannerIndicator.setIndicatorSource(
ContextCompat.getDrawable(getBaseContext(), R.drawable.select_bg),//select
ContextCompat.getDrawable(getBaseContext(), R.drawable.select_bg_no),//unselect
50//widthAndHeight
);
banner.attachIndicator(bannerIndicator);
//----------------------indicator end------------------------------banner.setOnBannerItemClickListener(new Banner.OnBannerItemClickListener() {
@Override
public void onItemClick(int position) {
Toast.makeText(getBaseContext(), "position:" + position, Toast.LENGTH_SHORT).show();
}
});
```
## LICENSECopyright 2016 yan
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.