【问题标题】:Javacameraview full width as that of the bounding layoutJavacameraview 全宽作为边界布局
【发布时间】:2017-07-27 04:12:53
【问题描述】:

我使用以下代码在布局中显示相机视图。

<?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 的全宽和全高。它占据了高度,但框架的宽度没有完全占据,因此宽度旁边有一个黑色背景。我怎样才能解决这个问题?

【问题讨论】:

    标签: android opencv javacameraview


    【解决方案1】:
    <?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>
    

    【讨论】:

    • 我希望相机只占据屏幕的一部分
    • 你可以使用margin。
    • 我只是在JavaCameraView 中添加了一个边距属性。但是很难理解你的布局。你能为我们发布设计吗
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-23
    • 1970-01-01
    • 2017-09-10
    • 1970-01-01
    • 1970-01-01
    • 2014-07-04
    • 2019-10-07
    相关资源
    最近更新 更多