In my android app development, I have one button, the button text is not a single color text, it is two lines text, with each line uses different color for line text. How to implement this? "Two lines" can be simply implemented by adding 开发者_运维知识库"\n" in the text, I don know how to set different colors for each line text on the button. Anyone can help?
Try to use Html.fromHtml when setting text to a button:
Button button = (Button) getElementById(R.id.some_button);
button.setText(Html.fromHtml("<font color='red'>First line</font><br/><font color='blue'>Second line</font>"));
精彩评论