Android <include> ListView 没有占据它的高度

标签 android listview include height fill-parent

我这里有一个很奇怪的问题。在以下 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/

相关文章:

android - bitmap.compress 破坏画质

Android 在 View 下方绘制阴影 : dispatchDraw called often - any cache missed

java - 如何在 android studio 的弹出窗口中添加带滚动的 listView?

android - 全屏显示 ListView [Xamarin.Forms]

android - 使用 switch case 通过 ListView 从 fragment 打开 Activity 时出错

php - 首先为所有页面自动加载 config.php 文件

android - 带有 ListView : two dividers between list item and button 的 AlertDialog

android - 使用折叠工具栏布局实现 RecyclerView

android - findViewById在<include> d View 内的LinearLayout上返回null

tomcat - 是否可以在 facelet 页面中包含远程网页?