Search code examples
androidmultithreadingsurfaceview

Surfaceview or View for puzzle app


I am developing a jigsaw puzzle app. I have a lag when I drag a puzzle piece from one corner to another. specially in large puzzles. Currently I am using a View and draw on canvas. Would it improve if I use a Surfaceview?

I know its used to draw using background thread so UI thread can perfrom better. However, the puzzle piece is moved with user input on UI thread. The question is would surfaceview improve the perfromance?


Solution

  • Surfaceview approach is much better and has better performance. It is easier to implement. Based on the user input update the puzzle data. Then when thread execute redraw the puzzle with these new data. This way we can manage bigger puzzles as well.