Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
603 views
in Technique[技术] by (71.8m points)

android - 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...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...