I have spent the whole day debugging various ways to add custom ViewGroup
into another custom ViewGroup
and nearly went crazy because none of them works, and there is no official documentation or sample that shows how it can be done...
Basically, I have 2 custom ViewGroup
:
HorizontalDockView
extendsViewGroup
GameEntryView
extendsFrameLayout
HorizontalDockView
overrides onDraw
, onMeasure
, etc and everything is called normally and works perfectly.
However, when I create GameEntryView
from inside HorizontalDockView
's constructor and call addView(gameEntryView)
, the gameEntryView
will never ever show regardless of the layoutParams
, addView
called from whatever thread, or however I call, load, and setContentView on the parent HorizontalDockView
. If I list through the horizontalDockView.getChildAt();
all the gameEntryView
objects are still there.
Hopeless, I try to debug through GameEntryView's onDraw
, onMeasure
, dispatchDraw
methods and realized none of them actually get called! No.. not even once!
Do I need to iterate through all the child view in the parent (HorizontalDockView's) on* call and call the children's on* explicitly? I was just calling super.on*() on the parent.
I did call setWillNotDraw( false );
on both the parent and the child class.
How do I get the child to show up inside the parent's view? simple sample or existing small open source project is highly appreciated!
Thank you very much!