I have 5 LinearLayouts. For ease of writing and understanding, I'll refer to them as Views A - E.
View A is the parent of Views B, C, D, and E.
I have set the layout_weight to 8.0f for View A and the weights to 1.0f, 3.0f, 1.0f, 3.0f for Views B - E respectively.
I understand that this is for managing the empty space in the parent view, but I was hoping to size my View and subviews to own a percentage of the screen, rather than compete just for the free space.
However, this is all done programmatically, so should I set the height of the LinearLayouts to a coefficient of the getHeight()
method/accessor of it's parent (View A)? If so, then how can I get the height of the parent if the view hasn't yet been added to it's parent, which would set its height with MATCH_PARENT?
Since the getHeight()
method will return 0 for onCreate
, onStart
, and the first onResume
, I had to keep looking for an answer. I found ViewTreeObserver
and OnGlobalLayoutListener
, which will let me know when the Layout
s have been set. However, I would really appreciate having the height before any drawing occurs. Is that not possible?