开发者

(Android button) how to implement Two line text with different colors on one button

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>"));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜