我希望我的整個活動立即滾動,但嵌入在我的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 –