AGI AGI - 5 months ago 20
Android Question

My Camera preview on my camera app is not clear (Android)

I am using a Samsung Mega which is a large phone that is running KitKat (4.4.2). When I test my app on this phone, the preview appears like this:

Camera Preview from Samsung Mega

However, when I test on smaller phones, the preview is normal and clear. Also, those smaller phones are either running Marshmallow or Nougat. I don't have another small phone that is running KitKat to test.

When I take photos on the Mega, the pictures come out fine. But the preview is not showing clearly. Also, the preview width and height on the screen are showing correctly.

So, why is the preview not clear? And how can I fix this?

Please let me know if you need additional information.

UPDATE (02/23/2017):
Camera previews comparison. I've added a smaller phone preview. I've updated the image link above for the Samsung Mega so that the preview of the Mega and the preview shown below are previewing the same object (a softball) so they can be compared.

Smaller phone camera preview

AGI AGI
Answer Source

I realized that the problem was in my XML layout. For FrameLayout, I used "wrap_content" for the layout_height, when I should have used "match_parent". That fixed the problem and the buttons that were underneath the preview before, I just overlaid it on the preview now. Basically, I was squeezing the camera preview into a smaller area, which is what might've caused the color issue.