您的位置:首页 > 其它

如何给textview中的不同的内容设置不同的颜色和字体

2016-02-29 14:19 295 查看
1 可首先在style中设置不同的style

<style name="charge_power">

        <item name="android:textSize">@dimen/text_size_title</item>

        <item name="android:textColor">@color/text_color_40</item>

    </style>

......

2 SpannableString styleString = new SpannableString(".........");

styleString.setSpan(new TextAppearanceSpan(this,R.style.charge_power),0,str1.length(),Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

......

tv.setText(styleString,TextView.BufferType.SPANNABLE);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: