title: Android ViewTreeObserver.OnGlobalLayoutListener troubles
body: <p>I'm using <code>ViewTreeObserver.OnGlobalLayoutListener</code> in <code>onCreate()</code> method to get layout's width. It works great, but when I'm manipulating with variables in <code>onGlobalLayout()</code> callback changes doesn't kept outside it.</p>
  
  <p>For example, when I'm saving Layout's width in Activity's field it returns previous value or value by default (0 in my case) outside the <code>onGlobalLayout()</code> method. When I change variable's referenses they will be null outside the method.</p>
  
  <pre><code>layout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
  @Override
  public void onGlobalLayout() {
      width = layout.getWidth(); // width - activity's field
      Log.d("myLogs", width); //return rigth value
  }
  });
  Log.d("myLogs", width); //return 0
  </code></pre>
  
  <p>I have no idea how to deal with it, perhaps I need obtain width of <code>Layout</code> in another way.</p>
  
  <p>Thanks in advance)</p>