2

カメラアプリケーションの作成中に問題に直面しています。私のレイアウトはこんな感じです。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/mainLayout" >

<SurfaceView 
    android:id="@+id/surface"
    android:layout_width="240px"
    android:layout_height="160px" />

<!--  A horizontal blue line --> 
<View
    android:layout_width="match_parent"
    android:layout_height="1px"
    android:background="@color/blue"/>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <ScrollView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scrollbarAlwaysDrawVerticalTrack="true" >

        <TextView
            android:id="@+id/details1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@color/blue"
            android:textSize="12sp" />
    </ScrollView>

    <!-- A vertical blue line -->
    <View
    android:layout_width="1px"
    android:layout_height="match_parent"
    android:background="@color/blue"/>

    <TextView
            android:id="@+id/details2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@color/blue"
            android:textSize="12sp" 
            android:text="@string/about"/>
</LinearLayout>

システムがアクティビティを再開するのを防ぐために、この属性をマニフェストのアクティビティ タグに含めました。

android:configChanges="keyboardHidden|orientation|screenSize|keyboard|layoutDirection"

surfaceview にカメラのプレビューが表示されます。Camera オブジェクトでメソッドを呼び出さずに向きの変更を処理する必要があります。つまり、サーフェス ビューは、呼び出さなくてもカメラ プレビューの正しい向きを表示する必要がありますcamera.setDisplayOrientation()

でSurfaceViewを回転させようとしたのonConfigurationChanged()ですが、SurfaceViewは回転するとプレビューが表示されず、元の向きでしかプレビューが表示されません。

4

0 に答える 0