2014-10-30 3 views

ответ

1

Используйте SpannableString установить подстрока жирным шрифтом.

String completeString = "<your complete string here>"; 
    String subString = "<the substring you want in bold>"; 
    SpannableString ss = new SpannableString(completeString); 
    ClickableSpan clickableSpan = new ClickableSpan() { 
     @Override 
     public void onClick(View textView) { 
     } 

     @Override 
     public void updateDrawState(TextPaint ds) { 
      super.updateDrawState(ds); 
      ds.setUnderlineText(false); 
      ds.setTypeface(Typeface.BOLD); 
      ds.setColor(<color that you want>); 
     } 
    }; 

    if (completeString.indexOf(subString) > -1) 
     ss.setSpan(clickableSpan, completeString.indexOf(subString), completeString.indexOf(subString) + subString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); 

    textEdit.setText(ss, TextView.BufferType.SPANNABLE); 
2

использование ниже код: -

mTextBox.setText(Html.fromHtml("<b>" + Bold text+ "</b>" + "<br />" + 
      "<small>" + Small one+ "</small>" + "<br />" + 
      "<small>" + Small two+ "</small>")); 
Смежные вопросы