问题
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