나는 ArrayList<String>
많은 단어를 가지고 있습니다. 특정 단어를 색칠하고 싶습니다. 가능합니까? 어떻게 할 수 있습니까?
전의. 나는 이것을 내 ArrayList
:
나는 페라리 자동차를 좋아합니다.
어썸을 다른 색상으로 만들려면 어떻게해야하나요? 문장 부호 (,!)를 어떻게 색칠 할 수 있습니까?
이 시도..
첫 번째는
SpannableString WordtoSpan = new SpannableString("This is simple");
WordtoSpan.setSpan(new ForegroundColorSpan(Color.BLUE), 0, 7, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
//0 is starting character and 7 is ending character you need to specify it
textView.setText(WordtoSpan);
두 번째는
String styledText = "This is <font color='red'>simple</font>.";
textView.setText(Html.fromHtml(styledText), TextView.BufferType.SPANNABLE);
편집하다:
String txt = "partial colored #text";
int to_len = txt.length();
int sim_pos = txt.indexOf("#");
SpannableString WordtoSpan = new SpannableString(txt);
WordtoSpan.setSpan(new ForegroundColorSpan(Color.BLUE), sim_pos, to_len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
textView.setText(WordtoSpan);
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다