Android——使用具有自定义背景的 ListView 时如何删除多余的填充?

发布于 2024-11-18 16:13:30 字数 1096 浏览 8 评论 0原文

我有以下布局:

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

  <ListView  
        android:id="@+id/xxx"
        android:layout_width="fill_parent"  
        android:layout_height="fill_parent"
        android:textColor="#464C59"         
        android:divider="#A4C539"
        android:dividerHeight="1px">
   </ListView>

    <ImageView
        android:id="@+id/home_bottom_bar"
        android:src="@drawable/bottombar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:clickable="true"/>
</FrameLayout>

目标是在活动的底部有某种广告栏(其中包含项目列表)。它工作正常,除了一件事!吧台下方有一些额外的空间(它很小,但足够引人注目)。顺便说一句,所有的 padding 都设置为 0,那么这个空间从哪里来呢?

谢谢!

编辑

调查问题后,发现自定义背景 (#EAEAEA) 导致了这个额外的空间。但仍然不知道如何解决这个问题。

I have the following layout:

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

  <ListView  
        android:id="@+id/xxx"
        android:layout_width="fill_parent"  
        android:layout_height="fill_parent"
        android:textColor="#464C59"         
        android:divider="#A4C539"
        android:dividerHeight="1px">
   </ListView>

    <ImageView
        android:id="@+id/home_bottom_bar"
        android:src="@drawable/bottombar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:clickable="true"/>
</FrameLayout>

The goal is to have some sort of advertising bar at the bottom of the activity (which contains a list of items). It works ok, except for one thing! There is some sort of extra space just under the bar (it's very small but it's noticeable enough). By the way, all the paddings are set to 0 so where does this space come from?

Thanks!

EDIT

After investigating the issue, it turns out that the custom background (#EAEAEA) is causing this extra space. Still don't know how to fix this though.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

禾厶谷欠 2024-11-25 16:13:30

当你提到它是一个小的额外空间时,它可能是顶部和底部的微小渐变。由 ListView 创建,当它可滚动时。

您可以阅读有关 ListView 背景 的内容,这应该可以让您了解如果是由这种特殊梯度引起的,如何修复它。

这条渐变线显然也可以删除:选项卡主机中的额外线条

When you mention that it is a small extra space, it may be the tiny gradient at the top and bottom. Created by ListView, when it is made scrollable.

You may read about ListView Backgrounds, this should give you the idea on how to fix it, if it is caused by this special gradient.

This gradient line can apparently also be removed: extra line in tab host

简单气质女生网名 2024-11-25 16:13:30

您可能需要使用合并标签,因为每个活动的基本布局都是 FrameLayout。
(这可能会导致填充。不过我对此不是 100% 确定)
看这里

You may want to use the merge tag since every activitys base layout is a FrameLayout.
(This may cause the padding. Im not 100% sure on this one though)
Look here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文