Highlighting Text Color using Html.fromHtml() in Android?

后端 未结 9 1340
忘了有多久
忘了有多久 2020-11-28 19:26

I am developing an application in which there will be a search screen where user can search for specific keywords and that keyword should be highlighted. I have found Html.f

9条回答
  •  萌比男神i
    2020-11-28 20:03

    Using color value from xml resource:

    int labelColor = getResources().getColor(R.color.label_color);
    String сolorString = String.format("%X", labelColor).substring(2); // !!strip alpha value!!
    
    Html.fromHtml(String.format("text", сolorString), TextView.BufferType.SPANNABLE); 
    

提交回复
热议问题