问题
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.
[edited]
I don't want to use ListView for this. anyone help me on this. Thanks...
回答1:
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.
回答2:
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.
回答3:
You can to try that carousel with RecycleView. Link : Carousel DemoProject
来源:https://stackoverflow.com/questions/9942443/carousel-view-implementation-like-listview-scrolling