【问题标题】:ListView and footer - how to eliminate space between them?ListView 和页脚 - 如何消除它们之间的空间?
【发布时间】:2014-04-30 18:37:17
【问题描述】:

最后一个列表视图的元素和它的页脚之间有一种故障 - 它没有分隔线,但它有一个空间。所以,如果我制作一个黑色背景,例如,这个故障空间将是黑色的,等等。

我怎样才能消除这个间距?

View v = getLayoutInflater().inflate(R.layout.footer_for_main, null);
//adding a footer:
    lvMain.addFooterView(v);
<ListView
    android:id="@+id/lvMain"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/main_footer_tile_long"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/ver_main_donate_background_tile_long"
    android:divider="@drawable/linear"
    android:footerDividersEnabled="false"
    android:headerDividersEnabled="false"

    android:listSelector="@drawable/selector_main_list" >

</ListView>

【问题讨论】:

  • 如果你把这个android:layout_height="wrap_content"改成这个android:layout_height="match_parent"怎么办?
  • 您永远不应该将wrap_content 视为android:layout_heightListView。 ListView 上的wrap_content 违背了它的唯一目的。
  • 请发布您的活动代码
  • Xaver Kapeller,没用,结果一样,底部有间距

标签: android listview footer


【解决方案1】:

你可以试试:

footerView.setPadding(0, -3, 0, 0);

因为 3px 是分隔线的默认高度。

【讨论】:

  • 我编辑了帖子 - footerView 没有 .setDividerHeight(0);作为任何视图
  • 好点,这是ListView的一个方法。我已经编辑了答案。
  • 这真的只是让页脚消失。但底部的间距仍然存在
猜你喜欢
  • 2015-09-26
  • 1970-01-01
  • 2017-05-25
  • 2022-01-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多