Is it possible to set the color of a string directly in string.xml?

前端 未结 12 1019
轮回少年
轮回少年 2021-02-07 12:17

I mean something like:

Error!
12条回答
  •  我在风中等你
    2021-02-07 12:44

    In my experience, I stored color in strings.xml look like

    #ffffff

    When I have an View and set `

    nameView.setBackgroundColor(R.color.name_color);

    it's OK.

    But when I set color for text look like

    name_TextView.setTextColor(R.color.name_color);

    it's not Effect.

    If you get the same problem, just set

    name_TextView.setTextColor(Color.parseColor("code hexa of color you want"));

    Hope it help.

提交回复
热议问题