Coder Social home page Coder Social logo

grassjuly / bannerpager Goto Github PK

View Code? Open in Web Editor NEW

This project forked from joker-fu/bannerpager

0.0 1.0 0.0 11.75 MB

Android Banner 支持无限轮播、预显示前后页、指示器位置、颜色、大小修改、点击/选中监听、滚动速度控制、设置自动翻页和时间、手指触碰暂停翻页,离开自动翻页、默认提供缩放/卡片/手风琴/立方体翻页效果 ,支持recyclerview列表嵌套 自动控制轮播

License: Apache License 2.0

Kotlin 1.31% Java 98.69%

bannerpager's Introduction

BannerPager

效果图

how to use:

  1. 步骤一
    <com.joker.pager.BannerPager
        android:id="@+id/banner_pager0"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_marginBottom="10dp" />
  1. 步骤二
    //配置你需要的轮播参数
    final PagerOptions pagerOptions2 = new PagerOptions.Builder(this)
            .setTurnDuration(2000)
            .setIndicatorColor(Color.RED, Color.BLUE)
            .setIndicatorSize(16)
            .setPagePadding(16)
            .setPrePagerWidth(60)
            .setIndicatorAlign(RelativeLayout.CENTER_IN_PARENT)
            .setIndicatorMarginBottom(40)
            .build();
     
    //设置BannerPager
    bannerPager2
            .setPagerOptions(pagerOptions2)
            .setPages(data, new ViewHolderCreator<BannerPagerHolder>() {
                @Override
                public BannerPagerHolder createViewHolder() {
                    final View view = LayoutInflater.from(CommonBannerActivity.this).inflate(R.layout.item_image_banner, null);
                    return new BannerPagerHolder(view);
                }
            });
            
    
    //当前轮播的ViewHolder
    private class BannerPagerHolder extends ViewHolder<String> {

        private ImageView mImage;

        private BannerPagerHolder(View itemView) {
            super(itemView);
            mImage = itemView.findViewById(R.id.image);
        }

        @Override
        public void onBindView(View view, String data, int position) {
            Glide.with(mImage.getContext())
                    .load(data)
                    .into(mImage);
        }
    }
  1. 步骤三
    @Override
    protected void onResume() {
        super.onResume();
        //适当位置开启轮播
        bannerPager0.startTurning();
    }

    @Override
    protected void onPause() {
        super.onPause();
        //适当位置停止轮播
        bannerPager0.stopTurning();
    }

Library projects:

Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

    allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }

Step 2. Add the dependency

    dependencies {
        compile 'com.github.joker-fu:BannerPager:0.1.0'
    }

bannerpager's People

Contributors

joker-fu avatar

Watchers

James Cloos 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.