目的:
在listview的item中設定元件layout_weight
操作:
- 在item的xml中,每個元件設定layout_weight
- listview的設定,layout_width="match_parent"
Code:
<ListView
android:id="@+id/totalReview_detailLV"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2" >
</TextView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" >
</TextView>
</LinearLayout>
reference:
http://stackoverflow.com/a/28078042