3D旋转-透视 [英] 3D rotation - perspective

查看:116
本文介绍了3D旋转-透视的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

}
}

我有上面的代码,围绕Y轴旋转视图。问题在于,透视图似乎过于强烈-前景中的视图边缘太大,而背景中的边缘变得太小。有可能降低透视因素吗?

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?

推荐答案

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

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

So this is the solution for all screen densities.

这篇关于3D旋转-透视的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆