3D旋转 - 透视

Inc*_*ble 5 3d animation android rotation perspective

public class MainActivity extends Activity {

LinearLayout rotator;

protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    rotator = (LinearLayout) findViewById(R.id.rotator);

    ObjectAnimator rotation = ObjectAnimator.ofFloat(rotator, "rotationY", 0, 360);
    rotation.setDuration(3000);
    rotation.start();

}
}
Run Code Online (Sandbox Code Playgroud)

我有上面的代码,它围绕Y轴旋转View.问题是,透视图似乎太"强烈" - 前景中的视图边缘变得太大而背景中的边缘变得太小.是否有可能"降低"透视因素?

Inc*_*ble 8

int distance = 1900;
float scale = getResources().getDisplayMetrics().density;
rotator.setCameraDistance(distance * scale);
Run Code Online (Sandbox Code Playgroud)

所以这是所有屏幕密度的解决方案.