2012-03-30 102 views
1

任何人都已经实现了像下面的carousel? 注意:项目列表不应重复,意味着在到达最后一个项目后不应先到达。请帮助我。像列表视图滚动一样的传送视图实现

carousel listview

[编辑]

enter image description here

我不想使用的ListView这一点。 任何人都可以帮助我解决这个问题。谢谢...

+1

看一看[此帖](HTTP://www.codeproject .com/Articles/146145/Android-3D-Carousel) – 2012-03-30 12:08:42

+0

你做了那个项目吗?我需要垂直的,你可以分享一些示例代码吗? – 2012-08-20 09:00:16

+0

@mustafa使用下面的Renard解决方案来处理垂直的。 – Noundla 2012-08-21 04:47:30

回答

4

这应该让你开始。重写你的ListView像这样:

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)。 一个很好的教程(它使用的另一种技术,可以发现here

+0

通过上面的列表视图项目是基于位置获取彼此之间的一些空间。但我不需要,所以我如何删除该空间.. – Noundla 2012-04-03 06:52:16

+0

@Renard我怎么能实现这一个http://stackoverflow.com/questions/20417882/list-view-with-change-width-of-row-什么时候滚动android的? – kyogs 2013-12-31 12:02:40

1

这可以使用自定义列表视图来实现。在列表活动中使用适配器将使其成为可能。一看here会让你更清楚。