android-Camera2Basic icon indicating copy to clipboard operation
android-Camera2Basic copied to clipboard

image preview is stretched in 18:9 aspect ratio devices

Open returnZro opened this issue 8 years ago • 6 comments

On running the Camera2Basic in 18:9 screen aspect ratio devices, the image preview and captured image is getting stretched.

screenshot_camera2basic

I am requesting the mPreviewSize of 1440 X 1080 while the device's available resolution is 1912 X 1080.

Tried several suggestions available but none worked.

returnZro avatar Jun 27 '18 13:06 returnZro

Check the width and height in your xml texture view. This is mine, had "match_parent" before and in my Constraint Layout, it is constrained to the top only, not the bottom,

  <com.guanacodevs.cardreader.AutoFitTextureView
        android:id="@+id/texture_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:backgroundTint="#000"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

GuanacoDevs avatar Jun 27 '18 15:06 GuanacoDevs

GuanacoDevs Very nice!!

GaldinoJr avatar Sep 05 '18 17:09 GaldinoJr

Did you find a solution?

I have fullscreen app with landscape orientation, no action bar, no status bar TextureView matches parent (width and height), but still 1440x1080...

It's not about view, map.getOutputSizes(SurfaceTexture.class); returns 1440x1080 as maximum

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.jack.mainactivity.MainActivity">
    
    <TextureView
        android:id="@+id/texture"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
    
</RelativeLayout>

more about issue:

https://stackoverflow.com/questions/52374888/camera2-1440x1080-is-maximum

https://github.com/googlesamples/android-Camera2Basic/blob/master/Application/src/main/java/com/example/android/camera2basic/Camera2BasicFragment.java#L740

anonym24 avatar Sep 17 '18 20:09 anonym24

@GuanacoDevs please take a look at my issue

anonym24 avatar Sep 17 '18 20:09 anonym24

Hy, I've got the same problem than you. I think is the ConstraintLayout that change the ratio off the textureview, if you try a linearLayout, the probleme is gone... If you solve it with the ConstraintLayout, please let me know...

Tapia83 avatar Jun 25 '19 13:06 Tapia83

This sample has been migrated to a new location where we can accept Pull Requests (check README for more information).

As recommended by GitHub, we are closing all issues and pull requests now that this older repo will be archived.

If you still see this issue in the updated repo, please reopen the issue/PR there. Thank you!

codingjeremy avatar Sep 19 '19 22:09 codingjeremy