Android - 在 ScrollView 中使用 ExpandableListView 的relativelayout

标签 android android-layout scrollview android-relativelayout expandablelistview

我在 ScrollView 中遇到 ExpandableListView 问题。我的应用程序中有这样的布局:

 <?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>

看起来像这样:

enter image description here

但我看不到整个 ExpandableListView。只有一个组标题行可见(应该有两个),如果我展开它,我将看不到子项。如果我删除 android:layout_below="@+id/infoTable,则会有整个 ExpandableListView:

enter image description here

你知道问题出在哪里吗?

最佳答案

也许这会对你有帮助。将 ListView 放入 ScrollView 中,并根据其项目固定 ListView 的高度 How can I put a ListView into a ScrollView without it collapsing?

关于Android - 在 ScrollView 中使用 ExpandableListView 的relativelayout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23350212/

相关文章:

android - 如何在 android 中的 gridview 适配器的 getView() 内膨胀另一个布局?

android - Android 上的 Youtube 播放器 - 无限加载

java - Android 工作室崩溃了。任何项目都行不通,有红线

android - 使用 RecyclerView + AppBarLayout

android - 如何将滚动添加到 Android 布局?

ios - CollectionView 中没有禁用 ScrollView ?

jquery - 指向同一页面上的位置的链接不匹配

以编程方式重置 Android 出厂设置

android - 目前是否有任何支持的 DrawerLayout 替代品?

android - 需要在用户位置周围使用不同颜色的边框圆圈