Code Monkey home page Code Monkey logo

custombanner's Introduction

CustomBanner

自定义的轮播图

##1、添加依赖:

app\build.gradle

dependencies { ... compile 'com.github.langxing:CustomBanner:1.0' }

.\build.gradle

allprojects { repositories { jcenter() maven { url "https://jitpack.io" } } }

##2、布局: <com.example.bannerlibrary.Banner android:id="@+id/banner" android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="gone" app:dotHei="2dp" app:dotMar="10dp" app:dotWid="10dp" app:dotScr="@drawable/dot_selector">

##3、属性说明: * dotHei 小圆点的高 * dotWid 小圆点的宽 * dotMar 小圆点左右间隔 * dotScr 小圆点背景,只支持图片选择器

##4、Java:

   banner = (Banner) findViewById(R.id.banner);
   List<Integer> ids = new ArrayList<>();
   ids.add(R.mipmap.image1);
   ids.add(R.mipmap.image2);
   //ids支持int和String
   banner.setIds(ids);        

##5、setOnPagerClickListener: 当前点击页面的监听事件

banner.setOnPagerClickListener(new Banner.OnPagerClickListener() { @Override public void onClick(int position, ImageView imageView) { Toast.makeText(MainActivity.this, position + "", Toast.LENGTH_SHORT).show(); } });

##6、setOnPageSelectedListener: 当前显示页面的监听事件

banner.setOnPageSelectedListener(new Banner.OnPageSelectedListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

       }

       @Override
       public void onPageSelected(int position) {

       }

       @Override
       public void onPageScrollStateChanged(int state) {

       }
   });

##7、有问题反馈 在使用中有任何问题,欢迎反馈给我,可以用以下联系方式跟我交流

custombanner's People

Contributors

langxing avatar

Stargazers

 avatar  avatar

Watchers

 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.