How to know when an activity finishes a layout pass?

前端 未结 3 1058
我在风中等你
我在风中等你 2020-12-10 01:15

I have a background thread that updates the UI of my activity, after the onCreate(). It can be adding layouts, or changing the size of others.

I simply

3条回答
  •  清歌不尽
    2020-12-10 01:45

    A GlobalLayoutListener will fire an event on completion of a layout. Would that suit your needs?

    View myView=findViewById(R.id.myView);
      myView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                    //At this point the layout is complete and the 
                    //dimensions of myView and any child views are known.
                }
            });
    

提交回复
热议问题