title: Setting the width of TextView
body: <p>I am creating a TextView and setting LayoutParams for the same.
  But when i display the TextView the size is 0.</p>
  
  <p>Below is my code:</p>
  
  <pre><code>TextView t = new TextView(getBaseContext());
  t.setBackgroundResource(R.drawable.roundbox);
  t.setText(new String("Hi").toCharArray(), 0, 2);
  
  LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(width, height);
  lp.bottomMargin = 10;
  lp.gravity = Gravity.RIGHT;
  t.setLayoutParams(lp);
  </code></pre>
  
  <p>The roundbox.xml content is:</p>
  
  <pre><code>&lt;shape xmlns:android="http://schemas.android.com/apk/res/android"
  android:shape="rectangle"&gt;
          &lt;corners android:radius="8dp"/&gt;
      &lt;solid android:color="#FFFFFF"/&gt;
      &lt;stroke android:width="1dp" android:color="#4fa5d5"/&gt;
  &lt;/shape&gt;
  </code></pre>
  
  <p>Can you please let me know what should i set as width and height in the LayoutParams constructor. I am setting some arbitrary value but i want the TextView size to be based on the amount of text in it.</p>