ScrollView中的可扩展列表视图有问题。我的应用程序中有此布局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/carType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text=" "
android:textAppearance="?android:attr/textAppearanceMedium" />
<TableLayout
android:id="@+id/infoTable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/carType"
android:stretchColumns="*" >
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:paddingBottom="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"
android:text="@string/tire_replacement"
android:textStyle="bold" />
<TextView
android:id="@+id/tirereplacement"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:text="@string/add_date" />
</TableRow>
//...rows...
</TableLayout>
<ExpandableListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/infoTable" >
</ExpandableListView>
</RelativeLayout>
看起来像这样:
但我看不到整个可扩展列表视图。只有一个组标题行可见(shloud有两个),如果我展开它,就看不到子项。如果删除
android:layout_below="@+id/infoTable
,则有整个可展开列表视图:你知道,哪里会有问题?是吗?
最佳答案
// try this way,hope this will help you...
<?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="vertical">
<ScrollView
android:id="@+id/ScrollView01"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.70"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/carType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text=" "
android:textAppearance="?android:attr/textAppearanceMedium" />
<TableLayout
android:id="@+id/infoTable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/carType"
android:stretchColumns="*" >
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:paddingBottom="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"
android:text="@string/tire_replacement"
android:textStyle="bold" />
<TextView
android:id="@+id/tirereplacement"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:text="@string/add_date" />
</TableRow>
//...rows...
</TableLayout>
</RelativeLayout>
</ScrollView>
<ExpandableListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.30">
</ExpandableListView>
</LinearLayout>