旋转视图实现类似的ListView滚动 [英] Carousel view implementation like listview scrolling

查看:236
本文介绍了旋转视图实现类似的ListView滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都已经实现,如下面的转盘? 注:不应该被重复的项目清单,手段不应该先到达最后一个项目之后。请帮我在这。

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.

我不希望使用的ListView这一点。 任何人能帮助我在此。谢谢...

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

推荐答案

这应该让你开始。覆盖您的ListView像这样:

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;
}

在getChildStaticTransformation可以实现各种效果(即使是3D),通过相应操作矩阵。 一个很好的教程(它采用另一种技术,可以发现<一href="http://developer.sonymobile.com/wp/2010/05/20/android-tutorial-making-your-own-3d-list-part-1/"相对=nofollow>这里。

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.

这篇关于旋转视图实现类似的ListView滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆