roomtek
roomtek

Reputation: 3767

Android TextView weights

I have an issue where I want the left subtext TextView (in grey) to take priority weight in the LinearLayout over the TextView on the right (in yellow). The TextView on the right always seems to take priority, while the one on the left wrapped. Any help is appreciated.

TextView weights issue

the XML for the layout is like this:

<LinearLayout
    android:id="@+id/LinearLayout03"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="-4dip" >

    <TextView
        android:id="@+id/TextView_nowplaying"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:ellipsize="end"
        android:maxLines="3"
        android:singleLine="true"
        android:textColor="#ddd"
        android:textSize="13dip" >
    </TextView>

    <TextView
        android:id="@+id/TextView_listeners"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:singleLine="true"
        android:textColor="#aaa"
        android:textSize="13dip" >
    </TextView>

    <TextView
        android:id="@+id/TextView_bitrate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="4dip"
        android:singleLine="true"
        android:textColor="#aaa"
        android:textSize="13dip" >
    </TextView>
</LinearLayout>

Upvotes: 0

Views: 6968

Answers (1)

Praveena
Praveena

Reputation: 6941

Please assign and try weight to all the component of the LinearLayout

layout_width of all the child should be 0dp in a horizontal LinearLayout

Assign weightSum parameter to the parent LinearLayout

Upvotes: 2

Related Questions