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内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复