3D rotation - perspective

纵然是瞬间 提交于 2019-12-06 03:46:51

问题


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();

}
}

I've got above code, which is rotating View around Y axis. Problem is, that the perspective seems to be too "strong" - the edge of view that is in foreground becomes too big and the edge in background becomes too small. Is there any possibility to "lower down" the perspecitve factor?


回答1:


int distance = 1900;
float scale = getResources().getDisplayMetrics().density;
rotator.setCameraDistance(distance * scale);

So this is the solution for all screen densities.



来源:https://stackoverflow.com/questions/26512772/3d-rotation-perspective

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!