Sandeep
Sandeep

Reputation: 3344

Carousel view implementation like listview scrolling

Anyone has implemented like the below carousel? Note: The list of items should not be repeated, means should not come to first after reaching the last item. Please help me on this.

carousel listview

[edited]

enter image description here

I don't want to use ListView for this. anyone help me on this. Thanks...

Upvotes: 1

Views: 5749

Answers (3)

Dima Kozhevin
Dima Kozhevin

Reputation: 3732

You can to try that carousel with RecycleView. Link : Carousel DemoProject

Upvotes: 0

Renard
Renard

Reputation: 6929

this should get you started. Override your ListView like so:

private final Transformation mTransformation;

public ListView3d(Context context, AttributeSet attrs) {
    super(context, attrs);
    if (!isInEditMode()) {
        setStaticTransformationsEnabled(true);
        mTransformation = new Transformation();
        mTransformation.setTransformationType(Transformation.TYPE_MATRIX);
    } else {
        mTransformation = null;
    }       
}

@Override
protected boolean getChildStaticTransformation(View child, Transformation t) {
    mTransformation.getMatrix().reset();
    final int childTop = Math.max(0,child.getTop());
    final int parentHeight = getHeight();
    final float scale = (float)(parentHeight-(childTop/2))/getHeight();
    Log.i("scale",scale+"");
    final float px = child.getLeft() + (child.getWidth()) / 2;
    final float py = child.getTop() + (child.getHeight()) / 2;
    mTransformation.getMatrix().postScale(scale, scale, px, py);
    t.compose(mTransformation);
    return true;
}

in getChildStaticTransformation you can achieve various effects (even 3d) by manipulating the matrix accordingly. A very good tutorial (which uses another technique can be found here.

Upvotes: 4

Anurag Ramdasan
Anurag Ramdasan

Reputation: 4340

this can be achieved using a custom list view. Using an adapter in a listactivity will make it possible. a look here will make it clearer for you.

Upvotes: 1

Related Questions