Giter Club home page Giter Club logo

roundbanner's Introduction

RoundBanner

Dribble上很火的那种圆角Banner
大部分代码来自 com.xuezj.cardbanner:cardbanner:1.0.0 针对部分代码加了一些优化
效果如下:
avatar

使用方式:
在项目的build.gradle里添加如下代码:
allprojects {
 repositories {
  ...
  maven { url 'https://jitpack.io' }
 }
}
然后添加依赖:
dependencies {
 implementation 'com.github.cahill377979485:RoundBanner:1.0'
}
使用方法:

        //获取数据,这里设置模拟数据
        List<String> listPictures = new ArrayList<>();
        List<String> listLinks = new ArrayList<>();
        //编造模拟数据
        String picUrl = "https://ss0.bdstatic.com/94oJfD_bAAcT8t7mm9GUKT-xh_/timg?image&quality=100&size=b4000_4000&sec=1588818908&di=c1428dc330be1d2d82cf83be2c695222&src=http://hbimg.b0.upaiyun.com/3804079cb84b828dc620501323a72e29a50e54328922-JRfbnX_fw658";
        String link = "https://www.baidu.com";
        for (int i = 0; i < 4; i++) {
            listPictures.add(picUrl);
            listLinks.add(link);
        }
        //装填数据
        myCardBanner.setDataCount(listPictures.size())
                .setBannerAdapter(new BannerAdapter() {
                    @Override
                    public BannerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                        return new MyBannerViewHolder(LayoutInflater.from(CardBannerActivity.this).inflate(R.layout.common_item_banner, parent, false));
                    }

                    @Override
                    public void onBindViewHolder(BannerViewHolder holder, int position) {
                        if (CardBannerActivity.this.isFinishing()) return;
                        MyBannerViewHolder viewHolder = (MyBannerViewHolder) holder;
                        String pic = listPictures.get(position);
                        Glide.with(CardBannerActivity.this)
                                .load(pic)
                                .centerCrop()
                                .diskCacheStrategy(DiskCacheStrategy.ALL)
//                    .bitmapTransform(new CropCircleTransformation(getContext()))
                                .into(viewHolder.riv);
                        viewHolder.riv.setOnLongClickListener(view -> {
                            Toast.makeText(CardBannerActivity.this, "查看大图" + pic, Toast.LENGTH_SHORT).show();
                            //todo 长按轮播图片跳转到查看大图页面,看具体业务需要不需要,不需要的话可以删掉。
                            return true;
                        });
                        viewHolder.riv.setOnClickListener((view -> {
                            String link = listLinks.get(position);
                            Toast.makeText(CardBannerActivity.this, "跳转网页" + link, Toast.LENGTH_SHORT).show();
                            //todo 点击轮播图片跳转到网页。
                        }));
                    }
                });
        //开始轮播
        myCardBanner.start();
        

具体用法,详看Demo的CardBannerActivity

roundbanner's People

Contributors

cahill377979485 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.