在我的应用中,我通过android.graphics.Camera
进行了三维变换。在我尝试使用Nexus之前,它似乎工作正常。
我在Nexus 7(4.2.1)和Galaxy Nexus(4.1.2)上安装了应用程序,两者都没有执行Camera转换。我有两个不同的视图与相机,都显示标准动画,不适用相机转换。
谁可以解释这种行为?
UPD: 相机代码
transformation.clear();
transformation.setTransformationType(Transformation.TYPE_MATRIX);
mCamera.save();
final Matrix matrix = transformation.getMatrix();
mCamera.translate(x,y,z);
mCamera.getMatrix(matrix);
matrix.preTranslate(-centerX, -centerY);
matrix.postTranslate(centerX, centerY);
mCamera.restore();
UPD2: 与Galaxy S3(4.2)相同,但不适用于S2(4.0.4)
答案 0 :(得分:0)
只需添加到getChildStaticTransformation的末尾
if (android.os.Build.VERSION.SDK_INT >= 16 /*JellyBean*/) child.invalidate();
答案 1 :(得分:0)
米哈伊尔提供的解决方案在getChildStaticTransformation
结束时为我工作。
唯一的问题是始终会调用getChildStaticTransformation
方法。
我的解决方案是将代码放在每个项目的更新x,y,z值之后。
// items is a ArrayList of ControlItem for example
// x,y,z are custom property of ControlItem class
items.get(0).x = 250;
items.get(0).y = 100;
items.get(0).z = 0;
for ( ControlItem item : items )
{
// Item must be invalidate with JellyBean and superior
if ( android.os.Build.VERSION.SDK_INT >= 16 ) item.invalidate();
}
// getChildStaticTransformation() will be called after, transformation will be applied