Android - onDraw not being called in dynamically inserted user view

I have a custom view that is dynamically inserted and onDrawnot called. I initially made a custom view without dynamic insertion, and it worked fine, however when I move it to the working code base I can’t get onDrawto receive the call ever, even if the view constructor is called, and onMeasurealso gets called. I tried to place calls to invalidate()and postInvalidate()around the site, but they do not seem to make the kind of draw. The presentation hierarchy looks the same for both versions, and I'm lost.

Can anyone help?

EDIT: A few more tests showed that the call onDrawcalls the emulator, but not the phone. In addition, onSizeChangedthe tube has the correct values, but on the emulator, all values ​​are 0.

EDITOR: I played with him and still can’t leave anywhere, so I put a bounty on him. If you need more code / xml / info, then please let me know.

+3
source share
2 answers

I changed Viewto TextView, and now it works, although I'm a little confused why it Viewdoes not work.

+1
source

, , . , ? ?

, requestLayout(), ( , - ). , .

+1

Source: https://habr.com/ru/post/1778584/


All Articles