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:

Enable HP Zbook Thunderbolt 3 Dock on Ubuntu

As mention in previously post, I installed Ubuntu on my HP ZBook. After two days used all things work just fine, but the Thunderbolt 3 Dock ...