Android ListView background colors always showing grey

前端 未结 6 1012
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-04 23:27

I have a ListView that I\'m populating from a custom ListAdapter. Inside the Adapter (in the getView(int, View, ViewGroup) method) I\'m setting the background color of the V

相关标签:
6条回答
  • 2021-01-04 23:55

    I ran into a similar problem where the divider was coming up grey. I found that the other solutions had no effect, but android:divider="<drawable,color, or whatever>" on my ListView worked.

    0 讨论(0)
  • 2021-01-04 23:57

    You cold always wrap the whole row inside another view and set the background color on that view. This view would be the first (and only) child of the row.

    0 讨论(0)
  • 2021-01-05 00:02

    You must set the cacheColorHint attribute to the desired background color for your list. This is a required workaround to account for a drawing optimization Android performs on lists.

    See here: link text

    0 讨论(0)
  • 2021-01-05 00:06

    try this:

    setBackgroundColor(0xFF5DB9FB);
    
    0 讨论(0)
  • 2021-01-05 00:11

    You should use: setBackgroundResource(R.color.myRow_red) instead of setBackgroundColor(). In your example background color is assigned with the ID instead of the actual color described in the resources.

    0 讨论(0)
  • 2021-01-05 00:15

    Try to do like this:

    av.setBackgroundColor(getResources().getColor(R.color.myRow_red));

    0 讨论(0)
提交回复
热议问题