Extended SurfaceView's onDraw() method never called
Solution 1:
Found it on the android-developers Google group. You simply have to add :
setWillNotDraw(false)
To the constructor. Now if someone could explain me why, that would be greatly appreciated.
Solution 2:
Minor correction:
Adding setWillNotDraw(false) to the constructor will cause crashes, because the underlying Surface object is not created yet.
Instead, put the setWillNotDraw(false) statement into the surfaceCreated() method. This delays the call until there's a real object to work with, and works properly.
(and many thanks to the users who posted this solution, it solved a major problem for me)
Solution 3:
Romain Guy explained it:
For efficiency, layouts do not get their
onDraw()
method called. To enable it, callsetWillNotDrawEnabled(false)
(or set the equivalent XML attribute to false.)