我有一个ListView,我从自定义ListAdapter填充。在适配器内部(在getView(int, View, ViewGroup)方法中)我使用setBackgroundColor(int)设置了View的背景颜色。问题是,无论我设置背景的颜色是什么颜色,都会呈现深灰色。也许值得一提的是我使用Light主题。Android ListView的背景颜色总是显示灰色
相关(简化的)的码位:
的AndroidManifest.xml:
<activity
android:name=".MyActivity"
android:theme="@android:style/Theme.Light" />
MyAdapter.java:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = LayoutInflater.from(mContext);
View av = inflater.inflate(R.layout.my_row, parent, false);
av.setBackgroundColor(R.color.myRow_red);
mName = (TextView) av.findViewById(R.id.myRow_name);
mName.setText("This is a name");
return av;
}
任何想法/建议?
谢谢你是一个救生员:) – user1940676 2013-10-07 08:27:16
我有类似的情况,但我不能使用此解决方案的形状。我在这里问了一个更详细的问题:http://stackoverflow.com/questions/39820240/android-canvas-drawrect-colour-always-shows-as-grey – Vedant261 2016-10-02 23:56:12