Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Behavior of setwillnotdraw(false)

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.

like image 632
Mohamed Samsudeen Avatar asked Dec 19 '15 19:12

Mohamed Samsudeen


1 Answers

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)

like image 197
Blackbelt Avatar answered Oct 19 '22 07:10

Blackbelt