Issue
I am new comer to the android and got stuck with this concept.
I have extended FrameLayout
and added child views. My child view's onDraw
is called even without setting setWillNotDraw(false)
. Then what is the actual need of it and when this flag should be set.
Solution
setWillNotDraw
is not required in a View
class.
However, it is usually set to true
in a ViewGroup
. Therefore, is disables the onDraw
method there.
If you need the onDraw
method to be called inside a ViewGroup
, you just set the flag to false
like so: setWillNotDraw(false)
.
Also, if you don't want that onDraw
in your view's subclass to be called, you have to call subclassInstance.setWillNotDraw(true)
Answered By - Blackbelt
Answer Checked By - Terry (JavaFixing Volunteer)