如何在Android的1.6或2创建列表视图这样的(因为的renderScript,它只能在3或更高版本的,但我需要清单的工作在几乎所有的机器人):安卓:垂直的ListView重叠的行
回答
我在drawChild中使用了Camera.setTranslate(x, 0, z)
,其中用于旋转虚拟化的x位置被改变,用于重叠的z被改变。然后有重叠的问题,因为最后一个项目在顶层,第一个在底层。所以,在onCreate()
方法称为this.setChildrenDrawingOrderEnabled(true)
和重写protected int getChildDrawingOrder (int childCount, int i) {}
在那里我可以为中期,后期行更改订单。 这个想法是由雷纳德给出的,他在我的其他帖子中提出了关于几乎相同的东西here。
我getChildDrawingOrder(INT,INT)实施得到重叠的,我需要:
@Override
protected int getChildDrawingOrder (int childCount, int i) {
int centerChild = 0;
//find center row
if ((childCount % 2) == 0) { //even childCount number
centerChild = childCount/2; // if childCount 8 (actualy 0 - 7), then 4 and 4-1 = 3 is in centre.
int otherCenterChild = centerChild - 1;
//Which more in center?
View child = this.getChildAt(centerChild);
final int top = child.getTop();
final int bottom = child.getBottom();
//if this row goes through center then this
final int absParentCenterY = getTop() + getHeight()/2;
//Log.i("even", i + " from " + (childCount - 1) + ", while centerChild = " + centerChild);
if ((top < absParentCenterY) && (bottom > absParentCenterY)) {
//this child is in center line, so it is last
//centerChild is in center, no need to change
} else {
centerChild = otherCenterChild;
}
}
else {//not even - done
centerChild = childCount/2;
//Log.i("not even", i + " from " + (childCount - 1) + ", while centerChild = " + centerChild);
}
int rez = i;
//find drawIndex by centerChild
if (i > centerChild) {
//below center
rez = (childCount - 1) - i + centerChild;
} else if (i == centerChild) {
//center row
//draw it last
rez = childCount - 1;
} else {
//above center - draw as always
// i < centerChild
rez = i;
}
//Log.i("return", "" + rez);
return rez;
}
我希望这篇文章将帮助别人在未来
截图实际上几乎是一样的,因为我在我的问题提到。我使用的α,所以重叠的项目是一点点透视:
@pengwang什么demo?你的意思是截图的结果? – 2012-04-25 10:57:24
是的,你是对的,你可以分享你的结果代码截图 – pengwang 2012-04-25 12:58:41
@PooLaS请给我的偏好链接,或发表您的班组长了解这件事情来实现。 – 2014-07-21 05:56:06
任何想法如何处理呢? – 2012-04-19 11:39:49