title: Android get layout height and width in a fragment
body: <p>I am working on a fragment and I want to get the dimension of a <code>layout</code> contained in the <code>xml</code> <code>fragment layout</code>.
  When I try the code </p>
  
  <pre><code>RelativeLayout myLayout = view.findViewById(R.id.myLayout);
  myLayout.getHeight();
  </code></pre>
  
  <p>it returns 0.
  I need these dimensions to put inside myLayout other objects.</p>
  
  <p>I try to use:</p>
  
  <pre><code>myLayout.getViewTreeObserver().addOnGlobalLayoutListener( 
      new ViewTreeObserver.OnGlobalLayoutListener(){
  
          @Override
          public void onGlobalLayout() {
              mHeight = myLayout.getHeight();  
              mWidth= myLayout.getWidth();
              System.out.println("width: "+mWidth+"   height: "+mHeight);
           }
  });
  </code></pre>
  
  <p>but this code is invoke a lot of time and I don't know exactly when it is execute.
  I need these dimensions into  <code>public void onActivityCreated ()</code> method. Is it possible? </p>