LinearLayout 在 ExpandableListView 中的工作方式不同

LinearLayout works differently in ExpandableListView

我正在尝试使用 ExpandableListView 实现图书内容选择器,但我发现 LinearLayout 在 ELV 中的工作方式似乎与在 activity 中的工作方式不同。

为了说明我正在尝试做的事情,这是我目前所处的位置:

屏幕截图

注意,当文本换行到下一行时,TextView 会填充可用的 space 并将垂直线(和 groupView 中的按钮)对齐到右侧(第 1.1 节和第 3 节),但是如果文本不换行,TextView 只占用它需要的空间 space。

这是子视图布局,组视图类似但有一个按钮。

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/white" >

        <View android:layout_width="3dp" android:layout_height="match_parent" android:background="#000000" />
        <View android:layout_width="10dp" android:layout_height="match_parent" />

        <TextView
            android:id="@+id/sectionNumber"
            android:layout_width="65sp"
            android:layout_height="wrap_content"
            android:textSize="18sp" />

        <TextView
            android:id="@+id/sectionTitle"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textSize="18sp" />

        <View android:layout_width="6dp" android:layout_height="match_parent" />
        <View android:layout_width="3dp" android:layout_height="match_parent" android:background="#000000" />

    </LinearLayout>

当我在 ExpandableListView 之外尝试此操作时,它按预期工作。我错过了什么?

问题出在片段 xml 布局的其他地方:

<ExpandableListView
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:id="@+id/expandableListView" />

layout_width 设置为 "wrap_content",应该是 "match_parent"