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

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

I mean something like:

Error!
12条回答
  •  误落风尘
    2021-02-07 12:45

    Its possible try this..

    string.xml

    Red color text.]]>
    

    ExampleClass.java

    TextView colorTextView = (TextView)findViewById(R.id.colorText);
    String customColorText = getResources().getString(R.string.colorText)
    colorTextView.setText(Html.fromHtml(customColorText));
    

    Happy coding....

提交回复
热议问题