3D动画/相机转换和现代设备



在我的应用程序中,我通过 android.graphics.Camera 进行了 3D 转换。在我尝试Nexus之前,它似乎工作正常。

我在Nexus 7(4.2.1)

和Galaxy Nexus(4.1.2)上安装了该应用程序,它们都根本不执行相机转换。我对相机有两种不同的视图,都显示标准动画,并且不应用相机变换。

谁能解释这种行为?

上级:相机代码

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)不同

只需添加到getChildStaticTransformation的末尾

if (android.os.Build.VERSION.SDK_INT >= 16 /*JellyBean*/) child.invalidate();

米哈伊尔提供的解决方案在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

最新更新