spannable on android for textView

前端 未结 3 423
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-30 04:33
Tweet o = tweets.get(position);

TextView tt = (TextView) v.findViewById(R.id.toptext);
//TextView bt = (TextView) v.findViewById(R.id.bottomtext);         

EditTex         


        
3条回答
  •  自闭症患者
    2020-11-30 05:10

    I want to make the font bold and ıtalic with spannable

    for this u will need to make o.content text as SpannableString then set it to TextView as :

    SpannableString spannablecontent=new SpannableString(o.content.toString());
    spannablecontent.setSpan(new StyleSpan(android.graphics.Typeface.BOLD_ITALIC), 
                             0,spannablecontent.length(), 0);
    // set Text here
    tt.setText(spannablecontent);
    

    EDIT : you can also use Html.fromHtml for making text Bold and Italic in textview as :

    tt.setText(Html.fromHtml(""+o.content+""));
    

提交回复
热议问题