Я попробовал рекомендуемый подход для определения размера строк в процентах в LinearLayout с использованием layout_weight, но безуспешно при переносе в ListView.XML-макет строки прекрасно выглядит в предварительном просмотре Eclipse, но столбцы запускаются вместе в реальном тестовом приложении.
Однако, если я обертываю ListView в TableLayout и TableRow, то он работает.
В приложении находится основной макет представления XML, который работает.Если вы удалите TableLayout и TableRow, удалив теги комментариев, произойдет сбой.
Может кто-нибудь объяснить, что происходит?
Есть ли лучшие способы сделать это?
===== Расположение строк =====
<?xml version="1.0" encoding="utf-8"?>
<!-- row.xml -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingTop="4dip"
android:paddingBottom="6dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="100"
android:orientation="horizontal">
<TextView android:id="@+id/one"
android:layout_width="0dip"
android:layout_weight="25"
android:textColor="#FFFFFF"
android:text="One"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/two"
android:layout_width="0dip"
android:layout_weight="25"
android:textColor="#FFFFFF"
android:text="Two"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/three"
android:layout_width="0dip"
android:layout_weight="50"
android:textColor="#FFFFFF"
android:text="Three"
android:layout_height="wrap_content"/>
</LinearLayout>
===== Главное расположение =====
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TableLayout
android:id="@+id/mainlist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="0"
android:paddingTop="4px" >
<TableRow>
<ListView
android:id="@+id/lview"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</ListView>
</TableRow>
</TableLayout>
</LinearLayout>