カメラアプリを作成しようとしましたが、この問題に直面しました。カメラを横向きモードで使用するとすべて問題ありませんが、縦向きでsetDisplayOrientation(90)メソッドを使用すると次の問題が発生します。
画面の半分が黒です。
ここの画像:http://i.stack.imgur.com/sPTex.jpg
surfaceCreatedメソッド:
@Override
public void surfaceCreated(SurfaceHolder holder) {
try {
this.camera = Camera.open();
this.camera.setDisplayOrientation(90);
this.camera.setPreviewDisplay(this.holder);
} catch (IOException e) {
e.printStackTrace();
}
}
私のXMLレイアウト
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/cameraPreview"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" >
</FrameLayout>
<Button
android:id="@+id/analyzeButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/analyze" />
</LinearLayout>
ちなみに、ADBで撮影したスクリーンショットでは、カメラは正常に表示されています。XperiaST27iでSamsungGalaxyPocketをテストしました-同じ結果です。
ありがとうございました