Marcos Vasconcelos Marcos Vasconcelos - 11 months ago 41
Android Question

Which Activity method is called after all the layout methods?

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.