我正在使用以下代码来显示布局中的相机视图。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:opencv="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true"
android:orientation="vertical"
android:weightSum="2">
<RelativeLayout
android:id="@+id/cam_frame"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary">
</LinearLayout>
<org.opencv.android.JavaCameraView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"
android:id="@+id/AddPersonPreview"
opencv:show_fps="false"
opencv:camera_id="any" />
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:background="@color/colorPrimary"
android:layout_weight="0">
</LinearLayout>
</LinearLayout>我正在尝试让相机视图占据全宽和全高,就像cam_frame一样。它占据了高度,但帧的宽度没有被完全占据,因此宽度旁边有一个黑色背景。我怎么才能解决这个问题呢?
发布于 2017-07-27 12:18:38
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:opencv="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/cam_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary">
</LinearLayout>
<org.opencv.android.JavaCameraView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"
android:layout_margin="30dp"
android:id="@+id/AddPersonPreview"
opencv:show_fps="false"
opencv:camera_id="any" />
</RelativeLayout>
</LinearLayout>https://stackoverflow.com/questions/45341283
复制相似问题