Skip to content Skip to sidebar Skip to footer

How To Understand That Android Finished Drawing A View?

Possible Duplicate: When has the Activity finished drawing itself? I want to know when a view completes its drawing, is that possible? How can I understand if android finished d

Solution 1:

Add a ViewTreeObserver to it.

Sample,

      TextView pagerView1=new TextView(this);
   ViewTreeObserver textViewTreeObserver=pagerView1.getViewTreeObserver();
        textViewTreeObserver.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

            publicvoidonGlobalLayout() {

                           //Do your operations here. 

                    pagerView1.removeGlobalOnLayoutListener(this);



            }
        });

This is a Listener which gets called once that particular gets drawn completely. So I have made it use for TextView. Similarly you can make use of any view you do. And inside onGlobalLayout() you can do your code.

Post a Comment for "How To Understand That Android Finished Drawing A View?"