android 通过html设置textview的内容不同种颜色

2023-05-26,,

代码:

		
String secondInfo = "<font color=\"#B7B7B7\">" + "空余位: " + "</font>"
					+ "<font color=\"#D95F5F\">" + "1072" + "</font>"
					+ "<font color=\"#B7B7B7\">" + " 总车位: "+"1162" + "</font>";
holder.tv_second.setText(Html.fromHtml(secondInfo));
			
			
String thirdInfo = "<font color=\"#B7B7B7\">" + "价格: " + "</font>"
					+ "<font color=\"#EAB547\">" + "61" + "</font>"
					+ "<font color=\"#B7B7B7\">" + " 元/小时" + "</font>";
holder.tv_third.setText(Html.fromHtml(thirdInfo));

效果:

《android 通过html设置textview的内容不同种颜色.doc》

下载本文的Word格式文档,以方便收藏与打印。