}
//控制gallery中每个图片的旋转(重写的gallery中方法)
protected boolean getChildStaticTransformation(View child, Transformation t) {
//取得当前子view的半径值
final int childCenter = getCenterOfView(child);
System.out.println(“childCenter:”+childCenter);
final int childWidth = child.getWidth();
//旋转角度
int rotationAngle = 0;
//重置转换状态
t.clear();
//设置转换类型
t.setTransformationType(Transformation.TYPE_MATRIX);
//如果图片位于中心位置不需要进行旋转
if (childCenter == mCoveflowCenter) {
transformImageBitmap((ImageView) child, t, 0);
} else {
//根据图片在gallery中的位置来计算图片的旋转角度
rotationAngle = (int) (((float) (mCoveflowCenter - childCenter) / childWidth) * mMaxRotationAngle);
System.out.println(“rotationAngle:” +rotationAngle);
//如果旋转角度绝对值大于最大旋转角度返回(-mMaxRotationAngle或mMaxRotationAngle;)
if (Math.abs(rotationAngle) > mMaxRotationAngle) {
rotationAngle = (rotationAngle < 0) ? -mMaxRotationAngle : mMaxRotationAngle;
}
transformImageBitmap((ImageView) child, t, rotationAngle);
}
return true;
}
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
mCoveflowCenter = getCenterOfCoverflow();
super.onSizeChanged(w, h, oldw, oldh);
}
private void transformImageBitmap(ImageView child