I need to programmatically adjust the sizes of views in my UI. Say I want to adjust the height of a child view to be the height of the parent view minus 60, I would do this:
child.getLayoutParams().height = parent.getMeasuredHeight() - 60;
child.requestLayout();
(obviously, this is simpler than what I really need to do)
This works great when it is done in response to, say, clicking a button or the like....the child view will adjust its size as requested, and all is well.
Now I need to also have the sizing done when the activity starts, and when the orientation changes. Preferably without seeing anything jump around. I tried adding it to the activity's onStart(), but that doesn't work, as the parent's height measures as zero. I also tried using getHeight() rather than getMeasuredHeight(), and got the same incorrect behavior.
Where do I put this code, or what do I need to do, to programmatically size the views?