spannable on android for textView

前端 未结 3 428
佛祖请我去吃肉
佛祖请我去吃肉 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:17

    SpannableString hint = new SpannableString(o.content.toString());
    

    Font size

    hint.setSpan(new RelativeSizeSpan(0.9f), 0, hint.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
    

    Font family

    hint.setSpan(new TypefaceSpan("sans-serif"), 0, hint.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
    

    italic

    hint.setSpan(new StyleSpan(Typeface.ITALIC), 0, s.length(), 0);
    

    color

    hint.setSpan(new ForegroundColorSpan(Color.GRAY), 0, hint.length(), 0);
    

    bold

    hint.setSpan(new StyleSpan(Typeface.BOLD), 0, hint.length(), 0);
    

    Reference link: https://www.programcreek.com/java-api-examples/index.php?api=android.text.style.RelativeSizeSpan

提交回复
热议问题