Skip to content Skip to sidebar Skip to footer

Linearlayout Layout_weight

I have a ListView that is populated with rows. These rows come from an XML file that looks like:
<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:orientation="horizontal"android:layout_width="fill_parent"android:layout_height="wrap_content"android:paddingLeft="8dip"android:weightSum="100"><TextViewandroid:layout_width="0dp"android:layout_height="wrap_content"android:id="@+id/columnA"android:layout_weight="2"android:layout_gravity="center"/><TextViewandroid:layout_width="0dp"android:layout_height="wrap_content"android:id="@+id/columnB"android:layout_weight="1"android:layout_gravity="center"/><ImageViewandroid:layout_width="0dp"android:layout_height="wrap_content"android:src="@drawable/icon"android:id="@+id/columnC"android:layout_weight="1"android:layout_gravity="center"
    ></ImageView><CheckBoxandroid:layout_width="0dp"android:layout_height="wrap_content"android:id="@+id/columnD"android:layout_weight="2"android:layout_gravity="center"/>

Solution 2:

I would think that you want columnC and columnB to have the same weight, but you have it set with them different.

Try

columnA:weight=2

columnB:weight=1

columnC:weight=1

columnD:weight=2

I have very limited experience with the weight attribute but I think this is how you can get your desired result.

If you're still having trouble with it, may help us help you if you can post a screen shot of how it looks, and how you want it to look.

Post a Comment for "Linearlayout Layout_weight"