Java Android布局xml旋转方向
我正在转换starter Android示例Camera2Video示例: 单独运行示例时,旋转效果良好,控件始终可见。然而,当我在Cordova插件中嵌入相同的代码时,控件在旋转时会消失 以下是布局xml:Java Android布局xml旋转方向,java,android,xml,cordova,layout,Java,Android,Xml,Cordova,Layout,我正在转换starter Android示例Camera2Video示例: 单独运行示例时,旋转效果良好,控件始终可见。然而,当我在Cordova插件中嵌入相同的代码时,控件在旋转时会消失 以下是布局xml: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.example.android.camera2video.AutoFitTextureView
android:id="@+id/texture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_below="@id/texture"
android:background="#4285f4">
<ImageButton
android:id="@+id/video"
style="@android:style/Widget.Material.Light.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:contentDescription="Record"
android:padding="20dp"
android:src="@drawable/record" />
<ImageButton
android:id="@+id/info"
android:contentDescription="Info"
style="@android:style/Widget.Material.Light.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right"
android:padding="20dp"
android:src="@drawable/gallery" />
</FrameLayout>
</RelativeLayout>
这是布局用地xml文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.example.android.camera2video.AutoFitTextureView
android:id="@+id/texture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_below="@id/texture"
android:layout_toRightOf="@id/texture"
android:background="#4285f4"
android:orientation="horizontal">
<ImageButton
android:id="@+id/video"
style="@android:style/Widget.Material.Light.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:contentDescription="Record"
android:padding="20dp"
android:src="@drawable/record" />
<ImageButton
android:id="@+id/info"
style="@android:style/Widget.Material.Light.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:contentDescription="Info"
android:padding="20dp"
android:src="@drawable/gallery" />
</FrameLayout>
</RelativeLayout>
还有检测旋转的代码
我相信这是一个简单的解决办法,我就是想不出来
我的完整插件代码:我使用以下代码解决了这个问题: 布局xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextureView
android:id="@+id/texture"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#66000000"
android:orientation="vertical">
<ImageButton
android:id="@+id/video"
style="@android:style/Widget.Material.Light.Button.Borderless"
android:layout_gravity="center"
android:contentDescription="Record"
android:padding="20dp"
android:src="@drawable/record"
android:layout_width="90dp"
android:layout_height="90dp"
android:scaleType="fitXY" />
<ImageButton
android:id="@+id/info"
android:contentDescription="Info"
style="@android:style/Widget.Material.Light.Button.Borderless"
android:layout_gravity="center_vertical|right"
android:padding="20dp"
android:src="@drawable/gallery"
android:layout_width="90dp"
android:layout_height="90dp"
android:scaleType="fitXY" />
</FrameLayout>
</RelativeLayout>
布局景观xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextureView
android:id="@+id/texture"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:background="#66000000"
android:orientation="horizontal">
<ImageButton
android:id="@+id/video"
style="@android:style/Widget.Material.Light.Button.Borderless"
android:layout_gravity="center"
android:contentDescription="Record"
android:padding="20dp"
android:src="@drawable/record"
android:layout_width="90dp"
android:layout_height="90dp"
android:scaleType="fitXY" />
<ImageButton
android:id="@+id/info"
android:contentDescription="Info"
style="@android:style/Widget.Material.Light.Button.Borderless"
android:layout_gravity="center_horizontal|bottom"
android:padding="20dp"
android:src="@drawable/gallery"
android:layout_width="90dp"
android:layout_height="90dp"
android:scaleType="fitXY" />
</FrameLayout>
</RelativeLayout>
您可以在这里看到它在我的cordova插件上工作:
我用以下代码解决了这个问题: 布局xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextureView
android:id="@+id/texture"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#66000000"
android:orientation="vertical">
<ImageButton
android:id="@+id/video"
style="@android:style/Widget.Material.Light.Button.Borderless"
android:layout_gravity="center"
android:contentDescription="Record"
android:padding="20dp"
android:src="@drawable/record"
android:layout_width="90dp"
android:layout_height="90dp"
android:scaleType="fitXY" />
<ImageButton
android:id="@+id/info"
android:contentDescription="Info"
style="@android:style/Widget.Material.Light.Button.Borderless"
android:layout_gravity="center_vertical|right"
android:padding="20dp"
android:src="@drawable/gallery"
android:layout_width="90dp"
android:layout_height="90dp"
android:scaleType="fitXY" />
</FrameLayout>
</RelativeLayout>
布局景观xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextureView
android:id="@+id/texture"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:background="#66000000"
android:orientation="horizontal">
<ImageButton
android:id="@+id/video"
style="@android:style/Widget.Material.Light.Button.Borderless"
android:layout_gravity="center"
android:contentDescription="Record"
android:padding="20dp"
android:src="@drawable/record"
android:layout_width="90dp"
android:layout_height="90dp"
android:scaleType="fitXY" />
<ImageButton
android:id="@+id/info"
android:contentDescription="Info"
style="@android:style/Widget.Material.Light.Button.Borderless"
android:layout_gravity="center_horizontal|bottom"
android:padding="20dp"
android:src="@drawable/gallery"
android:layout_width="90dp"
android:layout_height="90dp"
android:scaleType="fitXY" />
</FrameLayout>
</RelativeLayout>
您可以在这里看到它在我的cordova插件上工作: