0

在此处输入图像描述

我用于报告布局的 xml :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background"
    android:orientation="vertical" >
<ListView
        android:id="@+id/list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

    </ListView>

<TextView
    android:id="@+id/android:empty"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:text="@string/main_no_items"/>

</LinearLayout>

正如您在图像中看到的,列表项之间存在不必要的距离。我尽一切努力使列表项之间的距离最小化,但它永远不会减少:(我希望两个项目之间没有间隙。请指导我如何在一个列表项之后获得下一个项目,除了分区线之外没有间隙。

4

4 回答 4

1

该差距是因为LinearLayout您在row layout. 该背景图像的高度很长,这就是为什么它显示两个项目之间的差距。尝试使背景图像的高度更小,以达到您的要求。

于 2013-01-02T11:31:28.747 回答
0

尝试改变

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:background="@drawable/background"
android:orientation="vertical" >

android:layout_height="wrap_content"
于 2013-01-02T11:01:11.893 回答
0

永远不要在 raw_layout 中设置背景..

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:background="@drawable/background"         <-----  remove this line
android:orientation="vertical" >
于 2013-01-02T11:03:26.797 回答
0

从行的根布局中移除背景并将其应用到listview.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="?android:attr/listPreferredItemHeight"
      android:background="@drawable/background"  <===== Remove background
      android:orientation="vertical" >

报表布局中应用它

<ListView
    android:id="@+id/list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
     android:background="@drawable/background" /> <=== Try applying background in listview.
于 2013-01-02T11:11:10.997 回答