title: How to set specific width/height for view programmatically?
body: <p>I have a layout in xml layout file.<br/>
  At runtime, I wanna create 2 text view and them add into layout.<br/>
  => I cannot set width/height for 2 text view by my specific size.<br/>
  If I set <code>MATCH_PARENT</code>, it's OK.<br/>
  If I set by any specific size, it's only <code>WRAP_CONTENT</code></p>
  
  <p>XML layout file:<br/></p>
  
  <pre><code>&lt;LinearLayout 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="com.example.androidsnipcode.MainActivity$PlaceholderFragment"
      android:orientation="vertical"
      android:id="@+id/mylayout"&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><br/>
  Dimens.xml:<br/></p>
  
  <pre><code>&lt;resources&gt;
      &lt;!-- Default screen margins, per the Android Design guidelines. --&gt;
      &lt;dimen name="activity_horizontal_margin"&gt;16dp&lt;/dimen&gt;
      &lt;dimen name="activity_vertical_margin"&gt;16dp&lt;/dimen&gt;
      &lt;dimen name="heigh"&gt;300dip&lt;/dimen&gt;
      &lt;dimen name="width"&gt;600dip&lt;/dimen&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>onCreate() of Activity.java:<br/></p>
  
  <pre><code>LinearLayout layout = (LinearLayout) findViewById(R.id.mylayout);
  
          LinearLayout.LayoutParams layoutparams1 = new LinearLayout.LayoutParams(
                  LayoutParams.MATCH_PARENT, R.dimen.heigh);
          TextView tv = new TextView(this);
          tv.setLayoutParams(layoutparams1);
          tv.setText("hello 1");
          tv.setBackgroundColor(Color.CYAN);
          layout.addView(tv);
  
          LinearLayout.LayoutParams layoutparams2 = new LinearLayout.LayoutParams(
                  R.dimen.width, LayoutParams.MATCH_PARENT);
          TextView tv2 = new TextView(this);
          tv2.setLayoutParams(layoutparams2);
          tv2.setText("hello 2");
          tv2.setBackgroundColor(Color.MAGENTA);
          layout.addView(tv2);
  </code></pre>
  
  <p>Screen shot: height of first textview and width of second textview does not meet my expected (it's wrap content not my specific size)<br/> <img src="https://i.stack.imgur.com/uSxSZ.png" alt="height of first textview and width of second textview does not meet my expected"></p>