简体   繁体   中英

Android ListView divider different for every second row

So I have a 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>

My View looks like this :

 <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>

in @layout/item_supplier i have no red styling attributes.

在此处输入图片说明

So when I run the view it shows like this, my 2nd,4th etc... line are way more highlighted then the line between 1st and 2nd element.

Any ideas why?

This is a typically behaviour for an emulator. Some pixels get lost while painting of tiny objects like lines or dots.

Start your app on a real device and it should work properly.

Add below properties in your Listview And use your prefered color in android:divider And put Transparent Color in android:cacheColorHint like below:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM