我有一个进度对话框,我想显示如下所示的文本消息
- 正在下载
- 减压
我可以将“1.正在下载”显示为绿色,将“2.解压缩”显示为红色吗?我的代码在哪里
mProgressDialog.setMessage("1. Downloading \n 2. Decompressing");
最佳答案
看看这段代码。
final SpannableStringBuilder sb = new SpannableStringBuilder("your text here");
final ForegroundColorSpan fcs = new ForegroundColorSpan(Color.rgb(158, 158, 158));
// Span to set text color to some RGB value
final StyleSpan bss = new StyleSpan(android.graphics.Typeface.BOLD);
// Span to make text bold
sb.setSpan(fcs, 0, 4, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
// Set the text color for first 4 characters
sb.setSpan(bss, 0, 4, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
// make them also bold
yourTextView.setText(sb);
关于android - Android进度对话框消息中的两种颜色的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12833183/