Android 除非指定了高度,否则ListView仅呈现一个项目

Android 除非指定了高度,否则ListView仅呈现一个项目,android,listview,android-support-library,bottom-sheet,Android,Listview,Android Support Library,Bottom Sheet,我有一个上下文菜单,其中包含列表视图中的项目,所有项目都包含在ASL/Design库的底页中。活动的根视图是由BottomSheetBehavior指定的协调布局 我面临的问题是,如果列表视图容器的高度是wrap\u content或者甚至是match\u parent(下面是R.id.list\u container),则ListView(R.id.list\u container)仅呈现第一个列表项。如果此列表容器设置了一个较大的高度(例如:400dp),则完整列表将按预期呈现;以及额外的空

我有一个上下文菜单,其中包含
列表视图
中的项目,所有项目都包含在ASL/Design库的
底页
中。活动的根视图是由
BottomSheetBehavior
指定的
协调布局

我面临的问题是,如果列表视图容器的高度是
wrap\u content
或者甚至是
match\u parent
(下面是
R.id.list\u container
),则
ListView
R.id.list\u container
)仅呈现第一个列表项。如果此列表容器设置了一个较大的高度(例如:400dp),则完整列表将按预期呈现;以及额外的空间(因为高度超过规定)。
ListView
是动态填充的,因此我无法在布局xml文件中设置静态高度

是否有一个简单的布局、属性或编程解决方案,允许ListView在不过度分配垂直空间的情况下进行填充和渲染

我的初始配置如下所述



NestedScrollView
有自己的一组高度要求,以便完全渲染。我将其从层次结构中删除,列表在所有可用空间中呈现


感谢@CoderP的提示

为什么将ListView放在滚动视图中的线性布局中?默认情况下,AFAIK列表视图是可滚动的。
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:fitsSystemWindows="true">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/primaryBlue"
        android:orientation="vertical"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:fitsSystemWindows="true">

        <android.support.v7.widget.Toolbar android:id="@+id/toolbar"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"_elevation" />

        <!-- main activity content -->
        <FrameLayout
            android:id="@+id/content_frame"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/toolbar"
            />
    </RelativeLayout>

    <android.support.v4.widget.NestedScrollView
        android:id="@+id/bottom_sheet"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:clipToPadding="true"
        android:layout_gravity="bottom"
        app:behavior_hideable="true"
        app:layout_behavior="android.support.design.widget.BottomSheetBehavior">

        <!-- layout_height= 300dp / wrap_content -->
        <LinearLayout
            android:id="@+id/list_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <ListView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/problematic_list"
                />
            </LinearLayout>
    </android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>