Android:具有重叠行的垂直列表视图
如何在android 1.6或2中创建这样的列表视图(因为renderscript,它仅适用于3或更高版本,但我需要list才能在几乎所有Android上运行):
如何在android 1.6或2中创建这样的列表视图(因为renderscript,它仅适用于3或更高版本,但我需要list才能在几乎所有Android上运行):
我在drawChild中使用,其中更改了x位置以进行旋转虚拟化,z位置用于重叠。然后存在重叠问题,因为最后一项位于顶部,第一项位于底层。因此,在调用和重写的方法中,我可以更改中间行和后行的顺序。这个想法是由Renard给出的,他在我的其他帖子中向我推荐了几乎相同的东西。Camera.setTranslate(x, 0, z)
onCreate()
this.setChildrenDrawingOrderEnabled(true)
protected int getChildDrawingOrder (int childCount, int i) {}
我的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;
}
我希望这篇文章将来能帮助某人
屏幕截图实际上与我在问题中提到的几乎相同。我使用了 alpha,所以叠加的项目有点透视: