android - programmatically sizing views -
i need programmatically adjust sizes of views in ui. want adjust height of child view height of parent view minus 60, this:
child.getlayoutparams().height = parent.getmeasuredheight() - 60; child.requestlayout();
(obviously, simpler need do)
this works great when done in response to, say, clicking button or like....the child view adjust size requested, , well.
now need have sizing done when activity starts, , when orientation changes. preferably without seeing jump around. tried adding activity's onstart(), doesn't work, parent's height measures zero. tried using getheight() rather getmeasuredheight(), , got same incorrect behavior.
where put code, or need do, programmatically size views?
i encountered same problem. solution found on web using child.post() delay treatment in activity oncreate. works i'm doing, love hear better solution...
child.post(new runnable() { public void run() { //resize stuff } } );
Comments
Post a Comment