How Do I Hook A Moment When All Views Are Measured In My Activity?
I need to know correct widths, heights and positions of some of the views in my Activity ASAP after onResume. Where can I place this code in my Activity?
Solution 1:
Oddly, I get to reuse an answer the same day I make it:
You could set a global layout listener on the view tree in your onResume()
and do your diddling in there.
finalViewTreeObservervto= myView.getViewTreeObserver();
vto.addOnGlobalLayoutListener(newOnGlobalLayoutListener() {
publicvoidonGlobalLayout() {
// do layout tweaking based on measurements// remove the listener... or we'll be doing this a lot.
vto.removeGlobalOnLayoutListener(this);
}
}
Post a Comment for "How Do I Hook A Moment When All Views Are Measured In My Activity?"