3D 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(); } } 

I have a code that rotates around the Y axis. The problem is that the perspective seems too β€œstrong” - the edge of the view, which in the foreground becomes too large, and the edge in the background becomes too small. Is it possible to "lower" the coefficient perspecitve?

+5
source share
1 answer
 int distance = 1900; float scale = getResources().getDisplayMetrics().density; rotator.setCameraDistance(distance * scale); 

So, this is a solution for all screen densities.

+8
source

Source: https://habr.com/ru/post/1205294/


All Articles