I have made a program implementing Camera on surface view.
In landscape mode, the preview is correct, but in portrait mode the preview is tilted 180 degrees, it is not coming upright.
I have made a program implementing Camera on surface view.
In landscape mode, the preview is correct, but in portrait mode the preview is tilted 180 degrees, it is not coming upright.
如果您对您的应用程序始终处于横向模式感到满意,那么您应该将此行添加到您的清单中,它将消除您的问题:
<activity android:name=".YourActivity"
android:label="@string/app_name"
android:screenOrientation="landscape">
但是,如果您确实想要一个纵向模式应用程序,则可以将其添加到您的清单中:
<activity android:name=".YourActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
只要您将该mCamera.setDisplayOrientation(90);
行添加到您的活动中(前提是您检查了大于或等于 Froyo 的 android 版本。