Marcos Vasconcelos Marcos Vasconcelos - 1 year ago 54
Android Question

Which Activity method is called after all the layout methods have been called?

I need to do something in an

after all the layout methods have been called, all the
s are in place and the
is ready to be displayed.

Which method can do that?

Answer Source

If you are trying to get a width of a view or something. This should work

Add this to your activity's onCreate

ViewTreeObserver vto = layout.getViewTreeObserver(); 
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { 
    public void onGlobalLayout() { 
        // Put your code here. 

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download