Pergunta

I have problem with ExpandableListView in ScrollView. I have in my app this layout:

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

Looks like this:

enter image description here

But I can´t see whole ExpandableListView. Only one group header row is visible (there shloud be two) and If I expand it, I can´t see the child. If I remove android:layout_below="@+id/infoTable, there is whole ExpandableListView:

enter image description here

Do you know, where can be problem??

Foi útil?

Solução 2

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

Outras dicas

Maybe this will help you. put a ListView in a ScrollView and fix the height of ListView according to it's item How can I put a ListView into a ScrollView without it collapsing?

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top