Android banner based on Fresco.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.idea
banner
gradle/wrapper
projectFilesBackup/.idea
.gitignore
LICENSE
README.md
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

[TOC]

Banner

img

Android unlimited and auto scroll banner based on Fresco.

Image

gif

How to use

0 Import

0.1 By jitpack.io

	allprojects {
		repositories {
			...
			maven { url "https://jitpack.io" }
		}
	}
	dependencies {
	        compile 'com.github.aotian16:Banner:v1.0.8'
	}

0.2 Or Download this project and import as a module

1 Init fresco in Application

public class App extends Application {
    @Override
    public void onCreate() {
        super.onCreate();

        Fresco.initialize(this); // init Fresco
    }
}

2 Add net permission in AndroidManifest

<uses-permission android:name="android.permission.INTERNET"/>

3 Add BannerView in Layout

<com.qefee.pj.banner.view.BannerView
        android:id="@+id/bannerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

4 Run BnnerView in java

public class MainActivity extends AppCompatActivity {
    /**
     * log tag for MainActivity
     */
    private static final String TAG = "MainActivity";

    BannerView bannerView;

    String[] imageUris = {
            "https://pic4.zhimg.com/03b2d57be62b30f158f48f388c8f3f33_b.png",
            "https://pic1.zhimg.com/4373a4f045e5e9ae16ebd6a624bf6228_b.png",
            "https://pic2.zhimg.com/0364e17a1561f48793993d8bf1cdc785_b.png",
            "https://pic2.zhimg.com/55fa74ff3eba164ed1db2037df1a8311_b.png",
            "https://pic4.zhimg.com/5dc30569c06e7c6266c9809f6eb80a7b_b.jpg"
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        bannerView = (BannerView) findViewById(R.id.bannerView);

        bannerView.init(imageUris.length, new SimpleDraweeViewHandler() {
            @Override
            public void handle(int index, SimpleDraweeView view) {
              // custom SimpleDraweeView here
                view.getHierarchy().setPlaceholderImage(R.mipmap.ic_launcher); // placeholder image
                view.setImageURI(imageUris[index]);
            }
        });
    }

    @Override
    protected void onResume() {
        super.onResume();

        bannerView.startAutoScroll(); // auto scroll when resume
    }

    @Override
    protected void onPause() {
        super.onPause();

        bannerView.stopAutoScroll(); // stop auto scroll when pause
    }
}

Version

No. Version Detail
1 1.0.0 First version
2 1.0.1 fix bug
3 1.0.2 support custom view
4 1.0.3 update to gradle 2.14.1
5 1.0.4 update to fresco:0.13.0
6 1.0.5 update appcompat
7 1.0.6 add method startAutoScroll(long,long,TimeUnit)
8 1.0.7 update to fresco:0.14.1
9 1.0.8 update to appcompat-v7:25.0.0

LICENSE

MIT