当我的列表视图没有完整的列表视图项目(例如我的列表视图足够高达8个项目,但我只有2个)时,空白区域在我的Droid X上显示为灰色.在模拟器中,空白区域显示像黑色一样.
如何将"空"区域设置为透明?
我已经尝试设置背景颜色,缓存提示,但那些似乎只是更改listview的背景颜色,它有项目,而不是空白区域.
我的页面上有一个简单的列表视图.
<ListView
android:id="@+id/dinerListView"
android:layout_width="fill_parent"
android:layout_height="150dip"
android:layout_weight=".40"
android:background="@drawable/backrepeat"
android:cacheColorHint="#00000000"
android:layout_alignParentTop="true" />
Run Code Online (Sandbox Code Playgroud)
无论我将背景设置为 - 无论是图像还是颜色,它都会保持灰色.如果我使用行填充列表视图,则行背景颜色会相应显示.
此行为仅在姜饼手机(目前为droid x和droid 3)上展示.在模拟器和其他Froyo手机中,它工作正常.
所以我对listview有一个相当讨厌的问题.我的应用程序工作得很好,直到我的Droid 2上的Android 2.3.3更新.(似乎在三星Evo上工作正常)
这个问题有几个方面.1.空插槽中的背景始终为灰色.2.列表中的最后一个条目在被选中之前似乎是不可见的.选中后,您可以看到黑色文本,但没有背景.3.列表中的其他/旧条目显示正确的背景颜色.
我已经尝试了很多东西,似乎没有什么能解决这个问题.思考?
Listview定义
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:gravity="left|center"
android:layout_width="wrap_content"
android:layout_alignParentBottom="true"
android:paddingLeft="1px">
<TextView android:text=""
android:id="@+id/list_view_text_view"
android:layout_width="wrap_content"
android:textSize="13sp"
android:singleLine="false"
android:layout_height="wrap_content"
android:layout_marginLeft="1sp">
</TextView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
listview的主要布局
<ListView android:id="@+id/ListView01"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignRight="@+id/Button06"
android:layout_below="@+id/TextView01"
android:layout_alignLeft="@+id/TextView01"
android:layout_marginBottom="2sp"
android:layout_marginRight="2sp"
android:layout_marginLeft="2sp"
android:layout_above="@+id/EditText01"
android:transcriptMode="normal"
android:footerDividersEnabled="false"
android:headerDividersEnabled="false"
android:gravity="bottom"
>
</ListView>
Run Code Online (Sandbox Code Playgroud)
Listveiw适配器
private class EfficientAdapter extends BaseAdapter {
private LayoutInflater mInflater;
public EfficientAdapter(Context context) {
mInflater = LayoutInflater.from(context);
}
public int getCount() {
return comment_list.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int …Run Code Online (Sandbox Code Playgroud)