在我的OpenCV应用程序中,在以下布局中,根ViewGroup是具有FrameLayout
和android:layout_width="match_parent"
的android:layout_height="match_parent"
,并且具有no android:padding
。
此FrameLayout包含一个JavaCameraView
,它同时具有android:layout_width="match_parent"
和android:layout_height="match_parent"
,并且具有no android:layout_margin
。
因此JavaCameraView
应该跨越整个屏幕。但是,它上面和下面都有黑色填充。 如何摆脱JavaCameraView
上方和下方的填充?
根据this answer,JavaCameraView
继承自SurfaceView
。因此它应该在视图层次结构中尊重自身及其父级的layout_width和layout_height属性,对吗?
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<org.opencv.android.JavaCameraView
android:id="@+id/mainActivity_javaCameraView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
我迟到了4年,但希望这会对某人有所帮助。我在这里找到了解决方案:OpenCV Android Camera Not Fullscreen
我只是遵循了Juyel Rana博士提供的步骤,它的工作就像一种魅力。希望这会对某人有所帮助。