我是靠谱客的博主 迷你太阳,这篇文章主要介绍TextView的用法,现在分享给大家,希望可以做个参考。

1、textView设置两种不同颜色字体、大小

复制代码
1
2
3
4
5
6
7
8
TextView textView = new TextView(context); SpannableString styleText = new SpannableString("审批编号:" + bean7006.getData().getUserSchoolFlowOrder().getId()); styleText.setSpan(new TextAppearanceSpan(this, R.style.style0), 0, 5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); styleText.setSpan(new TextAppearanceSpan(this, R.style.style1), 5, String.valueOf(bean7006.getData().getUserSchoolFlowOrder().getId()).length() + 5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setText(styleText, TextView.BufferType.SPANNABLE); LinearLayout.LayoutParams ll = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); ll.setMargins(0, 10, 0, 0); linearSection.addView(textView, ll);
*引用的R.style.style0和R.style.style1为:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
<style name="style0"> <item name="android:textSize">14sp</item> <item name="android:textColor">@color/textcolorgary</item> </style> <style name="style1"> <item name="android:textSize">14sp</item> <item name="android:textColor">@color/textcolor</item> </style>


最后

以上就是迷你太阳最近收集整理的关于TextView的用法的全部内容,更多相关TextView内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(88)

评论列表共有 0 条评论

立即
投稿
返回
顶部