0

In my OpenCV app, in the following layout, the root ViewGroup is a FrameLayout with android:layout_width="match_parent" and android:layout_height="match_parent", and has no android:padding.

This FrameLayout contains a JavaCameraView which also has android:layout_width="match_parent" as well as android:layout_height="match_parent", and has no android:layout_margin.

So the JavaCameraView should span the entire screen. But instead, it has a black padding above and below it. How can I get rid of this padding above and below JavaCameraView?

According to this answer, JavaCameraView inherits from SurfaceView. So it should respect the layout_width and layout_height properties of itself and its parent in the view hierarchy right?

<?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>

enter image description here

Community
  • 1
  • 1
Solace
  • 8,612
  • 22
  • 95
  • 183
  • 1
    The surface view fills its parent. This is the camera picture not being rotated, cut off, or scaled to fit the surface view – David Medenjak Apr 09 '16 at 23:10
  • @DavidMedenjak You are right. I just tested that by giving the JavaCameraView a `android:background` color. It seems to fill the parent. But then I need the camera frame to fill the parent as well. Do you know how to force that camera frame to fill the parent? – Solace Apr 09 '16 at 23:21
  • 1
    I haven't done much with this myself, I just wanted to clear this misconception about padding – David Medenjak Apr 09 '16 at 23:23
  • @DavidMedenjak OK. Thank you for clarifying that =) – Solace Apr 09 '16 at 23:27

1 Answers1

0

I am 4 years late but hopefully this will help someone. I found a solution here: OpenCV Android Camera Not Fullscreen

I just followed the steps provided by Md Juyel Rana and it worked like a charm. Hopefully this will help someone.

Will
  • 804
  • 2
  • 8
  • 17