【问题标题】:Remove spacing between listview items删除列表视图项之间的间距
【发布时间】:2011-12-10 23:01:32
【问题描述】:

我正在尝试在 Android 中制作一个包含图像的 ListView。 我希望图像在列表中彼此正对,但我似乎无法消除间距。

这是我的 listview.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">    

<ListView
    android:id="@id/android:list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:drawSelectorOnTop="false"
    android:divider="@android:color/transparent"
    android:dividerHeight="0.0px"
    android:padding="0dip"
    android:layout_margin="0dip"
/>

</LinearLayout>

这是我的 listrow.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/vw01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">    

<ImageView android:id="@+id/img01"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="0dip"
    android:layout_margin="0dip"/>

</LinearLayout>

您可以在这里看到我所说的间距: http://imgbucket.info/img/kad67sjsg/stackoverflow.png

【问题讨论】:

  • 这对我来说很好。您确定您的图片中没有透明像素吗?
  • 它对我来说也很好。这就是让我发疯的原因:) 我很确定没有透明像素。我使用的图片在这里:imgbucket.info/img/1dbvyxqvi/bluebrick.png
  • 我不确定,但您是否尝试将“minHeight=0dip”放入列表行的线性布局中?
  • 我没有。但它没有用。
  • 您的布局 xml 帮助我删除了我的项目之间的黑色边框!谢谢

标签: java android xml


【解决方案1】:

我解决了。

我缩小了图片的比例,这成功了,所以问题甚至不在代码中。 感谢您的建议。

【讨论】:

  • 就像我写的那样,问题不在代码中。我使用图像编辑器缩小了图像文件。
  • 感谢这对我也有帮助!
猜你喜欢
  • 2017-03-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多