SurfaceView flashes black on load

后端 未结 8 1564
忘了有多久
忘了有多久 2020-11-28 02:59

I have a drawing app that takes about 2-5 seconds to load the drawing for complicated drawings (done via an AsyncTask). For a better user experience, during thi

相关标签:
8条回答
  • 2020-11-28 03:59

    You need to make sure that onSurfaceChanged() doesn't return until you have completely drawn and posted the contents of the SurfaceView's Surface.

    0 讨论(0)
  • 2020-11-28 04:00

    I would not do this with two separate layouts.

    Try making your root element a RelativeLayout and then having the SurfaceView and ImageView be sibling children of that. Whatever happens with your threading etc, the ImageView should be drawn wholly opaque on top of the SurfaceView, so you won't get a flash.

    Once your worker thread has loaded the drawing and the SurfaceView can draw itself, remove the progress bar and ImageView from the view hierarchy.

    0 讨论(0)
提交回复
热议问题