MaterialBanner

Additional

Language
Java
Version
1.0.0 (Sep 23, 2016)
Created
Sep 23, 2016
Updated
Sep 23, 2016
Owner
Jack Fu (rtugeek)
Contributor
Jack Fu (rtugeek)
1
Activity
Badge
Generate
Download
Source code
APK file

Announcement

MaterialBanner

ScreenShot:

Idea from Google Trips:

Demo APK

Attrs

attr format default
indicatorMargin dimension 10dp
indicatorInside boolean true
indicatorGravity flag:left,center,right left
match boolean false

Gradle:

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.0'

XML

  <com.freegeek.android.materialbanner.MaterialBanner
      android:id="@+id/material_banner"
      android:layout_width="match_parent"
      app:match="true"
      android:layout_height="200dp"/>
  MaterialBanner materialBanner = (MaterialBanner) findViewById(R.id.material_banner);
  materialBanner.setPages(new ViewHolderCreator() {
            @Override
            public Object createHolder() {
                return new ImageHolderView();
            }
        },bannerData);
  //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

Listener

  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) {

            }
        });

Spread the word

Thanks to:

Android-ConvenientBanner
ViewPagerIndicator

License

        DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
                Version 2, December 2004

Copyright (C) 2004 Leon Fu <rtugeek@gmail.com>

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.