我这里有一个很奇怪的问题。在以下 xml 部分中,我尝试使用 include:
<!-- CONTENT --> <ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" android:fadingEdge="none"> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent"> <include android:id="@+id/summary" layout="@layout/view_summary" android:layout_width="fill_parent" android:layout_height="fill_parent"/> </LinearLayout> </ScrollView>
(该部分采用主线性布局,垂直方向,宽度和高度均设置为填充父级)
包含的 xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white">
<ListView android:id="@+id/news_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:cacheColorHint="@color/transparent"
android:background="@color/transparent" />
<Button android:id="@+id/news_load_more"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:text="Load more..."/>
</LinearLayout>
问题是 ListView 没有占据整个高度(屏幕的高度),只有一个列表项的大小。我曾尝试通过代码设置布局参数,但没有帮助。
欢迎任何想法。 谢谢。
最佳答案
不要将 ListView 放在 ScrollView 中。删除 ScrollView 。
关于Android <include> ListView 没有占据它的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6289421/