Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rtugeek/MaterialBanner
MaterialBanner
https://github.com/rtugeek/MaterialBanner
Last synced: about 1 month ago
JSON representation
MaterialBanner
- Host: GitHub
- URL: https://github.com/rtugeek/MaterialBanner
- Owner: rtugeek
- Created: 2016-09-23T08:59:46.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-08T14:03:32.000Z (over 6 years ago)
- Last Synced: 2024-10-03T16:35:12.931Z (2 months ago)
- Language: Java
- Homepage: https://github.com/rtugeek/MaterialBanner
- Size: 4.5 MB
- Stars: 81
- Watchers: 7
- Forks: 19
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-github-android-ui - MaterialBanner - MD风格的banner (轮播图)
README
# MaterialBanner
## ScreenShot:
![](https://github.com/rtugeek/MaterialBanner/blob/master/screenshot/GIF.gif)## Idea from Google Trips:
![](https://github.com/rtugeek/MaterialBanner/blob/master/screenshot/googletrips.jpg)##[Demo APK](https://github.com/rtugeek/MaterialBanner/releases/download/1.0.0/Demo.apk)
### Attrs
|attr|format|default|
|---|---|---|
|indicatorMargin|dimension|10dp|
|indicatorInside|boolean|true|
|indicatorGravity|flag:left,center,right|left|
|match|boolean|false|### Gradle:
[![](https://jitpack.io/v/rtugeek/materialbanner.svg)](https://jitpack.io/#rtugeek/materialbanner) [![API](https://img.shields.io/badge/API-8%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=9) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-MaterialBanner-green.svg?style=true)](https://android-arsenal.com/details/1/3118)Step 1. Add the JitPack repository in your root build.gradle at the end of repositories:
```
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
```
Step 2. Add the dependency
```
compile 'com.github.rtugeek:materialbanner:1.0.2'
```XML
```xml
``````java
MaterialBanner materialBanner = (MaterialBanner) findViewById(R.id.material_banner);
materialBanner.setPages(new SimpleViewHolderCreator(), data)
.setIndicator(circlePageIndicator);
//set circle indicator
materialBanner.setIndicator(new CirclePageIndicator(this));
//indicators:
//CirclePageIndicator,IconPageIndicator,LinePageIndicator
//Custom indicator view needs to implement com.freegeek.android.materialbanner.view.indicator.PageIndicator
```[More usage](https://github.com/rtugeek/MaterialBanner/blob/master/app/src/main/java/com/freegeek/android/materialbanner/demo/MainActivity.java)
Listener
```java
materialBanner.setOnItemClickListener(new MaterialBanner.OnItemClickListener() {
@Override
public void onItemClick(int position) {
}
});
materialBanner.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {}
@Override
public void onPageSelected(int position) {
textView.setText("My hometown: page " + ++position);
}@Override
public void onPageScrollStateChanged(int state) {}
});
```### Customize
1.Create Holder,[See also SimpleHolder](https://github.com/rtugeek/MaterialBanner/blob/master/lib/src/main/java/com/freegeek/android/materialbanner/simple/SimpleHolder.java)[SimpleBannerData](https://github.com/rtugeek/MaterialBanner/blob/master/lib/src/main/java/com/freegeek/android/materialbanner/simple/SimpleBannerData.java)
```java
public class YourHolder implements Holder {@Override
public View createView(Context context) {
View view = LayoutInflater.from(context).inflate(R.layout.simple_banner_item,null);
//init your view here
return view;
}@Override
public void updateUI(Context context, int position, YourData data) {
//update your view here
}}
```
2.Create HolderCreator
```java
public class YourHolderCreator implements ViewHolderCreator{@Override
public YourHolder createHolder() {
return new YourHolder();
}}
```
3.Set your creator
```java
materialBanner.setPages(new YourHolderCreator(), list);
```**Spread the word**
## Thanks to:
[Android-ConvenientBanner](https://github.com/saiwu-bigkoo/Android-ConvenientBanner)
[ViewPagerIndicator](https://github.com/JakeWharton/ViewPagerIndicator)## License
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Jack Fu
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.