Android Gallery3D效果 教程 案例 代码

}

//控制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࿰

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值