Android Coverflow issue on 4.0.3 Samsung Galaxy S2

喜夏-厌秋 提交于 2019-12-03 00:33:44
Shantur

I just added

child.invalidate() 

before

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

so it becomes

protected boolean getChildStaticTransformation(View child, Transformation t) {

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

Are you using Neil Davies Coverflow Widget V2?

If yes, I found out the problem. If no, I am sorry, I can't help you.

The problem is in the function getCenterOfView. More accurate, it is a problem about view.getLeft(). <-- please tell me if anyone know why it is different after 4.0

The value return from view.getLeft() is different at every time. So this will affect another function getChildStaticTransformation, it can't find which imageview is the center.

My solution, a dirty fix, is give a range for it to detect its center.

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

Please let me know if anyone has a better solution on this.

I resolved following this code

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();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!