title: Android, How to get Width and Height of ViewGroup?
body: <p>In my app I need to know what is the size of main container of activity. I have written following code:</p>
  
  <pre><code>Button btnActionMenu = (Button) findViewById(R.id.actionbar_menu);
          btnActionMenu.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View v) {
                  int width = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 40, getResources().getDisplayMetrics());
                  RelativeLayout rlContainer = (RelativeLayout) findViewById(R.id.inner_content);
                  Bitmap bitmap = Bitmap.createBitmap(rlContainer.getLayoutParams().width, rlContainer.getLayoutParams().height, Config.ARGB_8888);//
                  Canvas canvas = new Canvas(bitmap);
                  rlContainer.draw(canvas);
                  SlideoutHelper.setBitmap(bitmap, width);
                  startActivity(new Intent(Home.this, MenuActivity.class));
                  overridePendingTransition(0, 0); 
              }
          });
  </code></pre>
  
  <p><code>rlContainer</code> is the root container of activity. When I run and click on button, the application crashes and Logcat says "<strong>Application Null pointer exception</strong>" and points to line</p>
  
  <pre><code>Bitmap bitmap = Bitmap.createBitmap(rlContainer.getLayoutParams().width, rlContainer.getLayoutParams().height, Config.ARGB_8888);
  </code></pre>
  
  <p>any suggestion would be appreciated. Thanks</p>