Skip to content

a type of recyclerview with on item on center and others evenly distributed

Notifications You must be signed in to change notification settings

zuoweitan/RecyclerCardView

Repository files navigation

RecyclerCardView & PaddingLayoutManager

both to support auto animate a item to center.

PaddingLayoutManager

A vertical LayoutManager only layout specified items with the some Gap.

Usage

PaddingLayoutManager layoutManager = new PaddingLayoutManager(this,visibled);

if you want run animation to your centerview,you just make you ViewHolder implements OnCenterProximityListener,just like this:

class SimpleCardHolder extends RecyclerCardView.ViewHolder implements OnCenterProximityListener{...}

Demo

RecyclerCardView

A vertical/horizonal list with one item on center and others evenly distributed up and down.

Vertical

Horizonal

How do I use it?

Setup

Gradle

dependencies {
  // jCenter
  compile 'com.vivifarm.view:RecyclerCardView:1.4.0'
}

Usage

demo

boolean vImg = false;//true to vertical demo

recyclerView = (RecyclerCardView) findViewById(R.id.recyclerView);
final CardLinearLayoutManager linearLayoutManager = new CardLinearLayoutManager(this,
        vImg? RecyclerCardView.VERTICAL : RecyclerView.HORIZONTAL,false);
recyclerView.setLayoutManager(linearLayoutManager);

SampleCardAdapter sampleCardAdapter = new SampleCardAdapter(recyclerView,3,vImg ? 0:60)
        .setvImg(vImg)
        .setList(list);
recyclerView.setAdapter(sampleCardAdapter);

cardSnapHelper = new LinearSnapHelper();
cardSnapHelper.attachToRecyclerView(recyclerView);

CardAdapter

Constructor

public CardAdapter(RecyclerView recyclerView,int visibleCount,int minNap){
   ...
}

note:

  1. visibleCount: number of visible, not support value 2.
  2. minNap : min value of both padding.(left and right or top and bottom).

CardHolder

class SimpleCardHolder extends RecyclerCardView.CardHolder<CardItem> implements RecyclerCardView.OnCenterProximityListener{
    @Override
    public void onCenterPosition(boolean animate) {
        ...
    }

    @Override
    public void onNonCenterPosition(boolean animate) {
        ...
    }
}

note:

  • your CardHolder can implement OnCenterProximityListener and do you animation on onCenterPosition,onNonCenterPosition.

About

a type of recyclerview with on item on center and others evenly distributed

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages