Android: ListView rounded corner hidden by list item

风流意气都作罢 提交于 2020-01-04 02:41:25

问题


I have this Listview element:

<ListView
android:id="@+id/category_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@drawable/list_background" 
android:layout_marginTop="10sp" 
android:layout_marginLeft="10sp" 
android:layout_marginRight="10sp"
android:drawSelectorOnTop="false"

android:listSelector="@drawable/list_item_background"           
android:cacheColorHint="#FFFFFF"            

android:clipToPadding="true"
android:focusable="true"
android:focusableInTouchMode="true"     
android:clickable="true"    
android:longClickable="true"

android:footerDividersEnabled="true"
android:headerDividersEnabled="true"
android:dividerHeight="1px"

/>

where list_background is:

<shape xmlns:android="http://schemas.android.com/apk/res/android">  
    <corners android:radius="10dp" /> 
    <solid android:color="#FFFFFF"/> 
</shape> 

The list view loads itself with the rounded corners, but then, the items of the list hide the round corners.

What am I doing wrong?


回答1:


I have found the solution to the problem.

I was using the android:cacheColorHint setting the same color as I wanted to have for the ListView background, this was leading to have the rounded corners to be hid when the list was scrolling and after the scroll.

So, setting it to "transparent" (#0000) solved the issue!




回答2:


maybe you have to disable the single item's background in the list, make it transparent so that it doesn't overlay the list



来源:https://stackoverflow.com/questions/4125185/android-listview-rounded-corner-hidden-by-list-item

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!