I have implemented a custom layout that extends ViewGroup. In its onLayout() method, I make a loop on all my children : I add them to the layout, measure them and then layout them. It works just fine.
But now I want my children to have dynamic content. So I have added a handler and a runnable to the viewholders of each of my children (my layout is populated with an adapter). This runnable aims at updating a textview every 10 seconds. What happens is that the TextView is truncated. I have found out that it actually takes the width of the first string it is set to and will never re-measure or re-layout again. I have decided to make my custom layout extend FrameLayout. And if in my onLayout() method I do call super.onLayout(), everything works just fine. Each time the TextView in the children is updated by the Runnable, I am called back on the onLayout method of my custom layout.
The big question is why ? Extending FrameLayout is not enough, I have to call super.onLayout(). I have checked the code of this method and can't figure out what it does to make it work. As layout is one pass top-down according to documentation, why calling this method makes my custom layout to be re-layouted each time a children is updated ? Please note that I have tried to call requestLayout() and invalidate() on my children to no avail.
Thanks for reading me. I can provide code if it is not clear enough.