both to support auto animate a item to center.
A vertical LayoutManager only layout specified items with the some Gap.
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{...}
A vertical/horizonal list with one item on center and others evenly distributed up and down.
dependencies {
// jCenter
compile 'com.vivifarm.view:RecyclerCardView:1.4.0'
}
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);
public CardAdapter(RecyclerView recyclerView,int visibleCount,int minNap){
...
}
note:
- visibleCount: number of visible, not support value 2.
- minNap : min value of both padding.(left and right or top and bottom).
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.