Coder Social home page Coder Social logo

gallery's Introduction

Gallery

通过RecyclerView实现的Gallery效果

主要特点是左右两边可以看到前后的边界。 效果如下:

使用步骤:

  1. 加入依赖
compile 'com.wan7451:gallery:1.0.1'
  1. 在布局中加入组件
<com.wan7451.gallery.Gallery
     android:id="@+id/gallery"
     android:layout_width="match_parent"
     android:layout_height="270dp" />
  1. 组件的简单配置
Gallery viewPager = (Gallery) findViewById(R.id.gallery);
viewPager.setClipWidth(dip2px(this, 20));  //左右两边边界的宽度  
viewPager.setInterval(dip2px(this, 10));   //itemView 之间的间隔距离
  1. 创建适配器
class QSAdapter extends GalleryAdapter<String> {
       
    public QSAdapter(Context context, ArrayList<String> list) {
        super(context, list);
    }
       
    @Override
    protected int getConvertLayout() {
        return R.layout.item_viewpager;
    }
    
    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        ImageView img = holder.getView(R.id.image);
        Glide.with(getContext()).load(getList().get(position))
            .centerCrop()
            .into(img);
    }
}
  1. 设置适配器
viewPager.setAdapter(new QSAdapter(this, data));

gallery's People

Contributors

wan7451 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

bagguo

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.