Android camera upside down

I followed this example. However, when I transfer it to my phone (to use the camera), the preview is flipped 90 degrees to the left. In addition, it works fine.

My question is: how do I “unlock” the preview ?

Here are the contents of my layout file:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal">   
        <android.view.SurfaceView xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/preview"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
    </android.view.SurfaceView> 
</LinearLayout>

In addition, when I try to rotate the phone myself, it remains in landscape mode.

Thanks in advance!

+3
source share
1 answer

I had the same problem. I just added a parameter to rotate the view 90. Add this parameter to the modified surface function:

parameters.setRotation(90); 
+1
source

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


All Articles