我希望我的整个活动立即滚动,但嵌入在我的ScrollView中的ListView不会展开。我只看到第一行,但是当滚动listView时,我可以滚动浏览其他行。 我需要的是为ListView高度扩展使其包含无需滚动列表视图,只有主滚动视图显示每个项目......Android:如何让listview在不滚动的情况下填充其父项?
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:orientation="vertical"
android:layout_weight="1" >
<LinearLayout
android:id="@+id/header_Layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
...
</LinearLayout>
<TextView
android:id="@+id/comment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="@drawable/gradient_background"
android:text="@string/comments"
android:textColor="#000000"
android:textStyle="bold" >
</TextView>
<ListView
android:id="@+id/commentsListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill"
android:divider="@drawable/gradient_divider"
android:dividerHeight="1dp" />
</LinearLayout>
</ScrollView>
你可以参考这篇文章http://stackoverflow.com/questions/3495890/how-can-i-put-a-listview-into-a-scrollview-without-it-collapsing –