【发布时间】:2014-04-09 08:54:14
【问题描述】:
所以我有一个 ListView。这些项目有自己的可绘制对象。
分隔线也是它自己的可绘制对象。
现在,当我有一个 ListView 时,如下面的屏幕截图所示,没有足够元素填充的空白区域,它只是白色。
我已经尝试设置缓存颜色提示,但这并没有解决它(老实说想不出任何其他可能有问题的地方)。
感谢任何帮助。
添加一些代码...
我的 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>
item_square 只是:
<?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>
item_green:
<?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>
【问题讨论】:
-
请注意...导航栏上方的白色区域就是我的意思(那个或中包条目下方的位置)。
-
请发布您的布局文件。
-
在列表视图中定义布局。您是否尝试添加 android:background="#00000000".
-
我已经编辑了问题以包含一些来源。 @LiemVo,我已经这样做了,但是没有任何改变。
-
如何设置列表视图的背景颜色?
标签: android listview background drawable