A
A
Aleksandr Koscheev2017-02-03 02:01:07
Java
Aleksandr Koscheev, 2017-02-03 02:01:07

How to rotate View using setRotationX?

There is a layout:

<View android:layout_width="300dp"
        android:layout_height="300dp"
        android:id="@+id/square"/>

And code:
@Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        View square= view.findViewById(R.id.square);
        square.setRotationX(45f);
    }

On different devices, you can see that the figure is drawn differently: 123a3d40b7ff472aad3e79140c7bc511.png
Question: how to rotate the View so that the result is the same on all devices?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question