简体   繁体   中英

Rounded corners become edgy when scrolling listview

I have a ListView in my Android app. The items have rounded corners defined like this:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<padding android:left="15dp" android:top="15dp" android:right="15dp"
    android:bottom="15dp" />
<solid android:color="@color/item_background" />
<corners android:radius="1dp" android:bottomLeftRadius="15dp"
    android:bottomRightRadius="15dp" android:topLeftRadius="15dp"
    android:topRightRadius="15dp" />
</shape>

When the ListView is displayed everything looks fine. But as soon as I start scrolling, the rounded corners get edgy and as soon as the scrolling stops they become rounded again.

Any ideas?

Try to set XML attribute android:scrollingCache="false" in your ListView. If it won't help try also android:cacheColorHint="#00000000"

这发生在我身上,因为我的 ListView 有android:layout_height="0dp" ,将其切换到android:layout_height="match_parent"

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