SetBackGroundColor没有效果的情况:
<ImageView
android:id="@+id/product_list_item_color_img"
android:layout_width="@dimen/keyline_1_minus_8dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true" />
mHolder.productColor.setBackgroundColor(colors[i]);
后来查资料发现是因为view在设置为wrap_content或者match_parent时如果view里面没有内容,此刻view的height会被设置为0,
所以不是因为SetBackGroundColor没有效果,是因为height为0所以看不出来,所以如果没有内容的view只需要给其设置一个固定的
值就可以了!
解决方法:
<ImageView
android:id="@+id/product_list_item_color_img"
android:layout_width="@dimen/keyline_1_minus_8dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true" />