title: android Layout weight programmatically
body: <p>i have hard-coded the layout_weight on layout xml.but now i want to give the layout_weight and weightSum from java code.</p>
  
  <p>How we do that from our class?   </p>
  
  <pre><code> &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="horizontal"
      android:weightSum="25" &gt;
  
      &lt;TextView
          android:id="@+id/textView1"
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_weight="5"
          android:background="#F51215"
          android:paddingLeft="5dip"
          android:text="5" /&gt;
  
      &lt;TextView
          android:id="@+id/textView2"
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_weight="20"
          android:background="#1AC92B"
          android:paddingLeft="5dip"
          android:text="20" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>