如何在android上一个按钮中设置两个不同大小的文本?
我试过settest(html.fromhtml),但是这个方法已经被弃用了。
最佳答案
请尝试以下操作:
Button button = FindViewById<Button>(Resource.Id.myButton);
SpannableStringBuilder spannable = new SpannableStringBuilder("Big Little");
spannable.SetSpan(new AbsoluteSizeSpan(50), 0, 3, SpanTypes.ExclusiveInclusive);
spannable.SetSpan(new AbsoluteSizeSpan(25), 4, 10, SpanTypes.ExclusiveInclusive);
button.SetText(spannable, TextView.BufferType.Editable);
更多信息:https://developer.android.com/guide/topics/text/spans