Android 如何滚动ExpandableListView?

Android 如何滚动ExpandableListView?,android,expandablelistview,Android,Expandablelistview,我有ExpandableListView,其中包含GroupView和ChildView。我在某种程度上设置了ExpandableListView高度,但它根本不滚动。为什么会这样 我也把它放在了ScrollView中,但没用 有人能帮我吗 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_he

我有ExpandableListView,其中包含GroupView和ChildView。我在某种程度上设置了ExpandableListView高度,但它根本不滚动。为什么会这样

我也把它放在了ScrollView中,但没用

有人能帮我吗

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="460dp"
android:background="@drawable/dealer_contact_body_bg"
android:orientation="vertical" >

<TableRow
    android:id="@+id/header"
    android:layout_width="match_parent"
    android:layout_height="70dp"
    android:background="@drawable/header_bg" >
</TableRow>

<TableRow
    android:id="@+id/load_header"
    android:layout_width="match_parent"
    android:layout_height="40dp"
    android:background="@drawable/il_header_bg" >

    <LinearLayout
        android:id="@+id/pick_insp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_weight="1" >

        <TextView
            android:id="@+id/header_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/pick_insp"
            android:textColor="@android:color/white"
            android:textSize="18dip"
            android:textStyle="bold" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/tripnumber"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_weight="1" >

        <TextView
            android:id="@+id/text2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/trip_no"
            android:textColor="#fff" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/driver"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_weight="1" >

        <TextView
            android:id="@+id/text3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/driver"
            android:textColor="#fff" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/date"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_weight="1" >

        <TextView
            android:id="@+id/text4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/date"
            android:textColor="#fff" />
    </LinearLayout>
</TableRow>

<TableRow
    android:id="@+id/pir_header"
    android:layout_width="match_parent"
    android:layout_height="40dp"
    android:background="@drawable/ir_vin_header_bg" >
</TableRow>

<ExpandableListView
    android:id="@+id/expandableListView2"
    android:layout_width="fill_parent"
    android:layout_height="260dp"
    android:scrollbars="vertical"
    android:clickable="true" >
</ExpandableListView>

<RelativeLayout
    android:id="@+id/relativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <Button
        android:id="@+id/signature_btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:background="@drawable/signature_btn" />
</RelativeLayout>

<LinearLayout
    android:id="@+id/toggle_layout"
    android:layout_width="match_parent"
    android:layout_height="120dp"
    android:layout_marginTop="65dp"
    android:background="@android:color/black"
    android:orientation="vertical" >

    <TableRow
        android:id="@+id/toggle_row"
        android:layout_width="fill_parent"
        android:layout_height="45dip"
        android:background="@drawable/il_header_bg" >

        <ToggleButton
            android:id="@+id/toggle_btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="990dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/icon_menu"
            android:textOff=""
            android:textOn="" />
    </TableRow>

    <RadioGroup
        android:id="@+id/radiogroup"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_gravity="bottom"
        android:layout_weight="1"
        android:background="@drawable/navbar_background"
        android:orientation="horizontal" >

        <RadioButton
            android:id="@+id/btn_trip"
            style="@style/navbar_button"
            android:drawableTop="@drawable/icon_trip"
            android:text="@string/trip" />

        <ImageView
            android:id="@+id/imgSep1"
            android:layout_width="3dp"
            android:layout_x="253dp"
            android:background="@drawable/menu_separation" />

        <RadioButton
            android:id="@+id/btn_inspection"
            style="@style/navbar_button"
            android:layout_marginLeft="5dp"
            android:drawableTop="@drawable/icon_inspection"
            android:text="@string/insp" />

        <ImageView
            android:id="@+id/imgSep2"
            android:layout_width="3dp"
            android:layout_x="509dp"
            android:background="@drawable/menu_separation" />

        <RadioButton
            android:id="@+id/btn_edvir"
            style="@style/navbar_button"
            android:layout_marginLeft="5dp"
            android:drawableTop="@drawable/icon_edvir"
            android:text="@string/edvir" />

        <ImageView
            android:id="@+id/imgSep3"
            android:layout_width="3dp"
            android:layout_x="765dp"
            android:background="@drawable/menu_separation" />

        <RadioButton
            android:id="@+id/btn_account"
            style="@style/navbar_button"
            android:layout_marginLeft="5dp"
            android:drawableTop="@drawable/icon_account"
            android:text="@string/account" />
    </RadioGroup>
</LinearLayout>


请任何人帮助我。

无需将其置于滚动视图中。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="460dp"
android:background="@drawable/dealer_contact_body_bg"
android:orientation="vertical" >

<TableRow
    android:id="@+id/header"
    android:layout_width="match_parent"
    android:layout_height="70dp"
    android:background="@drawable/header_bg" >
</TableRow>

<TableRow
    android:id="@+id/load_header"
    android:layout_width="match_parent"
    android:layout_height="40dp"
    android:background="@drawable/il_header_bg" >

    <LinearLayout
        android:id="@+id/pick_insp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_weight="1" >

        <TextView
            android:id="@+id/header_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/pick_insp"
            android:textColor="@android:color/white"
            android:textSize="18dip"
            android:textStyle="bold" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/tripnumber"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_weight="1" >

        <TextView
            android:id="@+id/text2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/trip_no"
            android:textColor="#fff" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/driver"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_weight="1" >

        <TextView
            android:id="@+id/text3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/driver"
            android:textColor="#fff" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/date"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_weight="1" >

        <TextView
            android:id="@+id/text4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/date"
            android:textColor="#fff" />
    </LinearLayout>
</TableRow>

<TableRow
    android:id="@+id/pir_header"
    android:layout_width="match_parent"
    android:layout_height="40dp"
    android:background="@drawable/ir_vin_header_bg" >
</TableRow>

<ExpandableListView
    android:id="@+id/expandableListView2"
    android:layout_width="fill_parent"
    android:layout_height="260dp"
    android:scrollbars="vertical"
    android:clickable="true" >
</ExpandableListView>

<RelativeLayout
    android:id="@+id/relativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <Button
        android:id="@+id/signature_btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:background="@drawable/signature_btn" />
</RelativeLayout>

<LinearLayout
    android:id="@+id/toggle_layout"
    android:layout_width="match_parent"
    android:layout_height="120dp"
    android:layout_marginTop="65dp"
    android:background="@android:color/black"
    android:orientation="vertical" >

    <TableRow
        android:id="@+id/toggle_row"
        android:layout_width="fill_parent"
        android:layout_height="45dip"
        android:background="@drawable/il_header_bg" >

        <ToggleButton
            android:id="@+id/toggle_btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="990dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/icon_menu"
            android:textOff=""
            android:textOn="" />
    </TableRow>

    <RadioGroup
        android:id="@+id/radiogroup"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_gravity="bottom"
        android:layout_weight="1"
        android:background="@drawable/navbar_background"
        android:orientation="horizontal" >

        <RadioButton
            android:id="@+id/btn_trip"
            style="@style/navbar_button"
            android:drawableTop="@drawable/icon_trip"
            android:text="@string/trip" />

        <ImageView
            android:id="@+id/imgSep1"
            android:layout_width="3dp"
            android:layout_x="253dp"
            android:background="@drawable/menu_separation" />

        <RadioButton
            android:id="@+id/btn_inspection"
            style="@style/navbar_button"
            android:layout_marginLeft="5dp"
            android:drawableTop="@drawable/icon_inspection"
            android:text="@string/insp" />

        <ImageView
            android:id="@+id/imgSep2"
            android:layout_width="3dp"
            android:layout_x="509dp"
            android:background="@drawable/menu_separation" />

        <RadioButton
            android:id="@+id/btn_edvir"
            style="@style/navbar_button"
            android:layout_marginLeft="5dp"
            android:drawableTop="@drawable/icon_edvir"
            android:text="@string/edvir" />

        <ImageView
            android:id="@+id/imgSep3"
            android:layout_width="3dp"
            android:layout_x="765dp"
            android:background="@drawable/menu_separation" />

        <RadioButton
            android:id="@+id/btn_account"
            style="@style/navbar_button"
            android:layout_marginLeft="5dp"
            android:drawableTop="@drawable/icon_account"
            android:text="@string/account" />
    </RadioGroup>
</LinearLayout>
默认情况下,ExpandableView具有滚动视图

您可能在可展开视图的高度或父视图高度方面出错。 下面是可扩展列表如何查找250的固定高度

 <ExpandableListView
        android:id="@+id/expandable_list_view"
        android:layout_width="fill_parent"
        android:layout_height="250dip"
        android:layout_marginBottom="20dip"
        android:background="@color/white"
        android:cacheColorHint="#00000000"
        android:clickable="true"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dip"
        android:fadingEdge="none"
        android:groupIndicator="@android:color/transparent"
        android:paddingLeft="10dip"
        android:paddingRight="10dip"
        android:scrollbars="none" >
    </ExpandableListView>

另外,请阅读有关可展开视图的内容:


*注意:如果未严格指定父级的大小,则不能使用XML中ExpandableListView的android:layout\u height属性的值wrap\u content(例如,如果父级为ScrollView,则无法指定换行内容,因为它也可以是任意长度。但是,如果ExpandableListView父级具有特定大小,例如100像素,则可以使用换行内容。*

发布布局代码,以便您可以知道自己做错了什么……有什么问题吗?谢谢您的回复。)…我会尝试这个解决方案