Android 每两行的 ListView 分隔符不同

Android ListView divider different for every second row

所以我有一个divider.xml

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

我的视图如下所示:

 <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <Mvx.MvxListView
            android:id="@+id/suppliersListView"
            android:divider="@drawable/divider"
            android:scrollbars="vertical"
            android:choiceMode="singleChoice"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="left|start" 
            local:MvxItemTemplate="@layout/item_supplier"
            local:MvxBind="ItemsSource ReceptionSuppliersList; ItemClick ReceptionBasicInformationSelectCommand"/>
    </LinearLayout>

在@layout/item_supplier 我没有红色样式属性。

所以当我 运行 视图显示如下时,我的第 2、4 等...行比第 1 和第 2 元素之间的行更突出。

知道为什么吗?

在您的 Listview 中添加以下属性并在 android:divider 中使用您喜欢的颜色并在 android:cacheColorHint 中添加透明颜色,如下所示:

android:divider="#00000000"
android:cacheColorHint="#00000000"
android:fadingEdge="none"

这是模拟器的典型行为。在绘制线条或点等微小对象时,一些像素会丢失。

在真实设备上启动您的应用,它应该可以正常运行。