Android:ListView项目填充不足时的背景色。[截图]

Android:ListView项目填充不足时的背景色。[截图],android,listview,background,drawable,Android,Listview,Background,Drawable,所以我有一个列表视图。这些物品都有自己的可拉丝 分隔器也是自己的可拉拔式 现在,当我有一个列表视图,如下面的屏幕截图所示,没有足够元素填充的空白区域,它只是白色的 我尝试过设置缓存颜色提示,但这并不能解决问题(老实说,我想不出还有什么其他问题) 感谢您的帮助 正在添加一些代码 我的ListView创建和属性: final ListView v = new ListView(this.getActivity()); fl.setBackgroundColor(Color.TRAN

所以我有一个列表视图。这些物品都有自己的可拉丝

分隔器也是自己的可拉拔式

现在,当我有一个列表视图,如下面的屏幕截图所示,没有足够元素填充的空白区域,它只是白色的

我尝试过设置缓存颜色提示,但这并不能解决问题(老实说,我想不出还有什么其他问题)

感谢您的帮助

正在添加一些代码

我的ListView创建和属性:

    final ListView v = new ListView(this.getActivity());
    fl.setBackgroundColor(Color.TRANSPARENT);
    v.setBackgroundDrawable(this.getActivity().getResources().getDrawable(R.drawable.item_selector_bad));
    v.setDivider(new ColorDrawable(Color.parseColor("#00000000")));
    v.setDivider(this.getActivity().getResources().getDrawable(R.drawable.item_square));
    v.setCacheColorHint(Color.TRANSPARENT);
    v.setSelector(this.getActivity().getResources().getDrawable(R.drawable.item_selector_bad));
    v.setDividerHeight(20);
至于xml文件,总体布局是这样的

列表中的项目具有:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:drawable="@drawable/item_square">
    </item>
    <item android:drawable="@drawable/item_green">
    </item>
</layer-list>

该项目仅为:

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/light_grid"
    android:tileMode="repeat" >

</bitmap>

该项目为绿色:

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

    <solid android:color="@color/light_green" />


    <corners
        android:bottomLeftRadius="25dp"
        android:bottomRightRadius="25dp"
        android:topLeftRadius="25dp"
        android:topRightRadius="25dp" />

</shape>

所以,我想到了这个解决方案,但是,我听说它的性能受到了影响。我想没那么糟糕,如果是的话,我一定会重新发布并增加悬赏。但是,您基本上只是让ListView使用包裹内容作为高度


他们还有更多类似的问题

作为一个注释。。。导航栏上方的白色区域就是我的意思(即中包条目下方的区域)。请发布布局文件。在listview中,在布局中定义。你是否尝试添加android:background=“#00000000”。我已经编辑了这个问题以包含一些源代码@LiemVo,我已经这样做了,但是没有任何变化。如何设置列表视图的背景色?