title: Android - onGlobalLayout is not called by ViewTreeObserver
body: <p>I have a headache in current Android project. I want to detect the changing of the current page. For example, there is a <strong>TextView</strong> to display device time, which is updated per second. How to detect this change? I searched a lot on SO (thanks SO), but none works for me.</p>
  
  <p>More information: I don't use standard Activity to create page. My way is:
  All widgets are created into a View object which is then used to create a container object. After that, I just handle this container to draw on a canvas with a <strong>VSYNC</strong> callback <strong><a href="https://developer.android.com/reference/android/view/Choreographer.FrameCallback.html" rel="nofollow noreferrer">Choreographer.FrameCallback</a></strong> periodically.</p>
  
  <p>Indeed, it works to draw. All are ok. Except: I want to draw <strong>canvas</strong> only when the page's content changed. So back to my beginning question, how to detect this "changing" event? I am sure there is some kind of callback to handle this problem. I used the following solution, but <strong><a href="https://developer.android.com/reference/android/view/ViewTreeObserver.OnGlobalLayoutListener.html" rel="nofollow noreferrer">onGlobalLayout</a></strong> is not called when textview's text changed.</p>
  
  <pre><code>CanvasAppViewContainer container;//CanvasAppViewContainer extends AbsoluteLayout
  LayoutInflater li =(LayoutInflater)getService().getSystemService(Context.LAYOUT_INFLATER_SERVICE);     
  
  View view = li.inflate(resourceId, null);//passed a correct the layout id
  container = new CanvasAppViewContainer(getService(), view, getWidth(), getHeight(), getSurface());
  rootView = (LinearLayout) findViewById(R.id.rootView); //root element of layout
  rootView.getViewTreeObserver().addOnGlobalLayoutListener(
      new ViewTreeObserver.OnGlobalLayoutListener() {
      @SuppressLint("NewApi")
      @Override
      public void onGlobalLayout() {
          Log.d("test", "onGlobalLayout");
      }
  });
  </code></pre>
  
  <p><strong>BTW:</strong> Even if I register the view tree observer for the textview, onGlobalLayout is still not called.</p>
  
  <p>Thanks</p>