Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/188.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 根据显示方向旋转surfaceview_Java_Android_Surfaceview_Screen Orientation - Fatal编程技术网

Java 根据显示方向旋转surfaceview

Java 根据显示方向旋转surfaceview,java,android,surfaceview,screen-orientation,Java,Android,Surfaceview,Screen Orientation,我在编写相机应用程序时遇到了一个问题。 我的布局是这样的 <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="vert

我在编写相机应用程序时遇到了一个问题。 我的布局是这样的

<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>
surfaceview将显示相机预览。 我必须在不调用摄影机对象上的任何方法的情况下处理方向更改,即曲面视图应显示摄影机预览的正确方向,而无需调用
Camera.setDisplayOrientation()

我尝试在
onConfigurationChanged()
中旋转surfaceview,但旋转时surfaceview不显示预览,而是仅以原始方向显示预览

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