我是靠谱客的博主 迷你太阳,最近开发中收集的这篇文章主要介绍TextView的用法,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

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

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为:

<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的用法所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

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

评论列表共有 0 条评论

立即
投稿
返回
顶部