Git Product home page Git Product logo

simplebanner's Introduction

simplebanner

GIF

原理

在adapter原来的数据的最前面插入最后面的元素,最后面同理,与viewpager那种size设置成无限相比,这样做性能相对更好,更节省内存。而size无限,单它的当前项为一个较大的数值,内部计算也会相应的增加计算压力。

include lib

Gradle:     个人并不提倡引包,本身作也就两个类,直接拷贝到项目会更方便,也好改indicator。

    compile 'com.yan.banner:banner:1.0.0'

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, Object 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();
        }
    });

LICENSE

Copyright 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 at

    http://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.

simplebanner's People

Contributors

genius158 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.