问题描述
如何在安卓1.6或2创建的ListView这样的(因为renderscript,其中仅在3或更高版本,但我需要清单的工作几乎所有机器人的):
How to create listview like this in android 1.6 or 2 (because of renderscript, which works only in 3 or later, but I need list to work on almost all androids):
推荐答案
我用 Camera.setTranslate(X,0,Z)
在drawChild,其中已更改X位置旋转的虚拟化和z为overlaping。再有就是问题重叠,因为最后一个项目是在顶部和第一个底层。所以,在的onCreate()
方法称为 this.setChildrenDrawingOrderEnabled(真)
和重写保护INT getChildDrawingOrder(INT childCount,int i)以{}
在那里我可以改变顺序中,晚三个行。这个想法被雷纳,谁建议我在等我的岗位约几乎同样的事情这里给出。
I used Camera.setTranslate(x, 0, z)
in drawChild, where changed x position for rotation virtualization and z for overlaping. Then there was problem with overlapping, because last item was on top and first on bottom layer. So, in onCreate()
method called this.setChildrenDrawingOrderEnabled(true)
and overriden protected int getChildDrawingOrder (int childCount, int i) {}
where I could change order for middle and later rows.This idea was given by Renard, who suggested me in other my post about almost same thing here.
我getChildDrawingOrder(INT,INT)实施得到重叠我需要:
My getChildDrawingOrder(int, int) implementation to get overlapping I need:
@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;
}
我希望这篇文章可以帮助别人的未来
I hope this post will help someone in future
截图其实是差不多,因为我在我的问题提到的相同。我用alpha通道,所以叠加的物品是一点点透视:
Screenshot is actually almost the same as I mentioned in my question. I used alpha, so overlayed items is a little bit see-through:
这篇关于安卓:垂直的ListView与overlaped行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!