我正在使用Android Coverflow,在大多数设备上都能正常工作,但在Android 4.0.3上,当您来回滑动时,似乎无法将中心图像放回中心位置。它们保持“卡住”并处于错误的角度下。是否有人遇到过类似的问题?这种行为可能是什么原因引起的?因此,所附图像中的中间图像应该居中,并且不应该倾斜。
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;
您是否正在使用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);
}
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();