【发布时间】:2025-12-30 16:45:11
【问题描述】:
我无法弄清楚如何使 ExpandableListView 不可滚动,始终处于全尺寸并定位在布局的底部,但如果 textView 超出范围,也保持滚动的能力。我知道不建议在 ScrollView 中使用 ListView。但是如何实现呢?现在一切看起来像这样:
布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/ic_launcher"
android:id="@+id/imageView2" />
<TextView
android:text="Order description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/imageView2"
android:id="@+id/orderDescr"
android:paddingTop="5dp" />
</RelativeLayout>
</ScrollView>
<TextView
android:text="label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView5"
android:paddingTop="15dp"
android:paddingLeft="16dp"
android:paddingRight="16dp" />
<ExpandableListView
android:id="@+id/expandableListView"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:indicatorLeft="?
android:attr/expandableListPreferredItemIndicatorLeft"
android:childDivider="#00000000"
android:layout_below="@+id/orderDescr"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="5dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:headerDividersEnabled="false"
android:footerDividersEnabled="false"
android:isScrollContainer="false" />
</LinearLayout>
【问题讨论】:
标签: android expandablelistview