android-Layout Gewicht programmgesteuert

habe ich hart codiert die layout_weight auf layout-xml.aber jetzt möchte ich die layout_weight und weightSum von java-code.

Wie wir tun, dass aus unserer Klasse?

 <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:weightSum="25" >

    <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" />

    <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" />
</LinearLayout>
InformationsquelleAutor ranjit patel | 2012-07-23
Schreibe einen Kommentar