在4.0.3 Samsung Galaxy S2上发布Android Coverflow问题

时间:2012-10-22 15:31:38

标签: android coverflow

我正在使用android coverflow,它在大多数设备上运行良好,但似乎在Android 4.0.3中,一旦你来回滑动它就不会将中心图像重新放回中心。

他们仍然“陷入困境”且处于错误的角度。

有没有人有过类似的问题?什么可能导致这种行为?

所以附着图像上的中间图像应该居中,而不是按原样成角度。

CowerFlow Issue

3 个答案:

答案 0 :(得分:17)

我刚刚添加了

child.invalidate() 

final int childCenter = getCenterOfView(child); in getChildStaticTransformation(View child, Transformation t) 

所以它变成了

protected boolean getChildStaticTransformation(View child, Transformation t) {

    child.invalidate();
    final int childCenter = getCenterOfView(child);
    final int childWidth = child.getWidth();
    int rotationAngle = 0;

答案 1 :(得分:3)

您使用的是Neil Davies Coverflow Widget V2吗?

如果是,我发现了问题。如果不是,我很抱歉,我帮不了你。

问题出在函数getCenterOfView中。更准确,这是view.getLeft()的一个问题。 < - 请告诉我,如果有人知道为什么它在4.0之后有所不同

view.getLeft()返回的值每次都不同。所以这会影响另一个函数getChildStaticTransformation,它无法找到哪个imageview是中心。

我的解决方案,一个肮脏的修复,为它提供一个检测其中心的范围。

if (childCenter <= mCoveflowCenter + 125
            && childCenter >= mCoveflowCenter - 125) {
        transformImageBitmap((ImageView) child, t, 0);
}

如果有人有更好的解决方案,请告诉我。

答案 2 :(得分:2)

我解决了以下代码

private int offsetChildrenLeftAndRight() {
    int offset = 0;
    for (int i = getChildCount() - 1; i >= 0; i--) {

        getChildAt(i).offsetLeftAndRight(offset);

        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN)
            getChildAt(i).invalidate();
    }
    return offset;
}


final int childCenter = getCenterOfView(child) + offsetChildrenLeftAndRight();
相关问题