Sunday, October 13, 2013

Why the screen flashes when adding a SurfaceView?

I tried to add a VideoView to a layout dynamic via code in my Android app, but the whole screen flashes when the VideoView was added first time. To make the problem simple, I changed the VideoView to SurfaceView, as VideoView extends SurfaceView, you know, but the issue was still there.

After all, I found out the 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 online in Activity:onCreate() to set pixel format, as below:

getWindow().setFormat(PixelFormat.TRANSLUCENT);

1 comment:

Thrift fails on Windows - thrift failed error: The command line is too long.

Meet a thrift compiling failure on my project on Windows 7. Using Maven in IntelliJ so I choiced maven-thrift-pluging for thrift files. For ...