title: get width, height from Layout
body: <p>I need to get width and height of Linear layout, however I do not know when the Relative Layout is ready to provide me these two attributes.</p>
  
  <p>but it only returns 0.</p>
  
  <p>my screen
  <a href="https://i.stack.imgur.com/OzLh8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OzLh8.png" alt="enter image description here"></a></p>
  
  <p>please check my code, i have no idea.</p>
  
  <pre><code>import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.util.Log;
  import android.widget.LinearLayout;
  
  public class MainActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
      }
  
      @Override
      protected void onResume() {
          super.onResume();
          LinearLayout container = (LinearLayout)findViewById(R.id.container);
          int width = container.getWidth();
          int height = container.getWidth();
  
          Log.d("MainActivity onCreate", "width #" + width + ", height #" + height);
      }
  }
  </code></pre>
  
  <p>and activity_main.xml layout</p>
  
  <pre><code>&lt;RelativeLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".MainActivity"&gt;
  
      &lt;LinearLayout
          android:background="#FFFFFFAA"
          android:orientation="vertical"
          android:id="@+id/container"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
      &lt;/LinearLayout&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>how do i fix this?</p>