How to set paint.setColor(R.color.white)

后端 未结 5 394
盖世英雄少女心
盖世英雄少女心 2020-12-29 23:09

I have a custom View that uses Paint and Canvas to draw objects. My question is how to set:

int color = R.color.white;
paint.setColor(color);
5条回答
  •  囚心锁ツ
    2020-12-29 23:43

    int color = ContextCompat.getColor(context, R.color.white);
    paint.setColor(color);
    

    The setColor() method takes a color number as int value, but not a resource id which is an int as well.

提交回复
热议问题