Android:出现在列表视图顶部的透明空间

Android:出现在列表视图顶部的透明空间,android,android-listview,gradient,Android,Android Listview,Gradient,我需要使用拉来刷新列表视图,所以我使用了相同的方法。我还需要在我的列表项上设置一个暗透明的背景。所以,我用了梯度。每件事都很好,除了在标题和listview之间的顶部出现一个小的空白,如下图所示,我需要删除它。我认为这是梯度的问题,而不是库的问题,因为我查看了库的源代码,但没有发现任何问题 下面是我的布局文件: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_

我需要使用拉来刷新列表视图,所以我使用了相同的方法。我还需要在我的列表项上设置一个暗透明的背景。所以,我用了梯度。每件事都很好,除了在标题和listview之间的顶部出现一个小的空白,如下图所示,我需要删除它。我认为这是梯度的问题,而不是库的问题,因为我查看了库的源代码,但没有发现任何问题

下面是我的布局文件:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_menu_list" >

<com.dzo.pulltorefresh.HeaderBar
    android:id="@+id/baseHeaderBar"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true" />

<com.handmark.pulltorefresh.library.PullToRefreshListView
    android:id="@+id/listMainMenu"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_below="@+id/baseHeaderBar"
    android:layout_marginBottom="55dp"
    android:cacheColorHint="#00000000"
    android:divider="#050505"
    android:dividerHeight="2dp" />

</RelativeLayout>

这是我使用的梯度:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<gradient 
    android:startColor="#77000000"
    android:centerColor="#88000000"
    android:endColor="#99000000"
    android:angle="270"/>
</shape>


只需将您的
相对背景更改为如下所示的暗背景即可:



你说的是标题和列表之间的白色空间吗?它的出现是因为你的根布局的背景色。只需将您的
RelativeLayout
background设置为
android:background=“@android:color/background\u dark”
,然后检查。您是在正常活动中还是在对话框(警报对话框)中显示listview?这是一个正常活动这是离题的,但您不应该尝试在android上复制iOS应用程序。这将导致谷歌没有特色,以及其他一些不好的事情。对不起,实际上相对布局的背景是一张图片。我在做一些改变,看看是否有什么不同,但我忘了恢复。我已经编辑了我的帖子。这不是我正在使用的实际背景。这是可绘制的
@drawable/bg_menu_list
是您的图像还是xml文件?您的图像是否包含白色?不,它只是一个城市的视图
  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:background="@android:color/background_dark" >