Reputation: 35
I want to use SurfaceView for animation to show the live camera preview. It is working fine. But when it loads for first time it flickering for first time.
Upvotes: 0
Views: 2014
Reputation: 954
Adding a 0px height blank surfaceView to the first layout of the activity might solve the issue. It is a crazy solution, but it solved the issue for me.
You could also check the following query which has a full explanation of answer. "SurfaceView flashes black on load"
Upvotes: 1
Reputation: 922
This is common issue with android surface view.
Window was destroyed then re-created when the SurfaceView was adding, and the Window's pixel format was changed mean while, that guided me to the answer, the pixel format of the SurfaceView and the Activity was different so Window Manager forced the re-created.
To resolve it, just added one line in onCreate() to set pixel format, as below:
getWindow().setFormat(PixelFormat.TRANSLUCENT);
Upvotes: 6