gpt4 book ai didi

android - 如何在android中为单个textview设置两种不同的大小

转载 作者:行者123 更新时间:2023-12-04 23:51:56 25 4
gpt4 key购买 nike

In my android app i need to set two different sizes in single textview. i tried Spannable but not working correctly. what i tried was


String Amount = "Rs.109";                                     
Spannable Passspan = new SpannableString(Amount);
Passspan.setSpan(new RelativeSizeSpan(0.75f), 1, 3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
txt.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
txt.setText(Passspan);

I want "Rs." as text size of 10 and rest of them as text size of 15. The total count of amount may vary to different sizes such as "Rs.109" , "Rs.1000" like that . guide me...

最佳答案

Thank you very much for your support guys...This helps me to get two different font size in single textview.


String Amount="Rs.109";
txt.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
Spannable span = new SpannableString(Amount);
span.setSpan(new RelativeSizeSpan(0.75f), 0, 3,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
txt.setText(span);

关于android - 如何在android中为单个textview设置两种不同的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25238158/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com