Domanda

I used to have a nice little fragment that loaded the camera in a frame (An image overlayed on top in a frame layout). After doing some refactoring to my code( which I have gone over Incessantly), I suddenly noticed that my camera didn't work.The SurfaceView that was supposed to show the camera was blank.

Over the last four hours, I added null checks and breakpoints everywhere. I could not find the source of the breakage. So then I swapped out most of my code for a line by line copy of the CommonsWare Camera example. The main difference is that my version was in a Fragment instead of an activity.

I understood most(if not all) of it while re-implementing it, and made it fit my current fragment based system. While it did not fix my bug, after a while I discovered that moving my SurfaceView above my ImageView worked. However, it did not provide the intended overlay effect as the frame was now effectively over the surface.

È stato utile?

Soluzione

...Until I found that I had set the fragment container to a Hardware layer and forgot to return it to normal.

Beware this line:

findViewById(R.id.fragment_container).setLayerType(View.LAYER_TYPE_HARDWARE, null);

It messes with camera rendering.


Hopefully this helps some other poor soul.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top