如何在运行时更改所选文本的字体大小的EditText? [英] How to change the font size of selected text in edittext at runtime?
问题描述
我开发一个文本编辑器,我的应用程序,其中我想编辑文本的选定部分。我几乎用它做除了一个功能,即可以减小所选文本的大小。
I am developing a text editor for my application, in which i want to edit the selected portion of text. And i am almost done with it except one feature, that to decrease the size of selected text.
我可以增加大小,如:
文本= editor.getText();
text.setSpan(新RelativeSizeSpan(2F),开始,结束,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
editor.setText(文本);
I could increase the size like :
text=editor.getText();
text.setSpan(new RelativeSizeSpan(2f), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
editor.setText(text);
但我坚持减小大小,如何文本的大小可以降低?
But i am stuck with decreasing the size, How the size of text can be decreased ?
推荐答案
尝试,你已经用于增加TEXTSIZE用code,如下图所示,其中编辑器是EditText上以同样的方式
try the same way as you have used for increase textsize used code as shown below where editor is EditText
Spannable text=(Spannable)editor.getText();
text.setSpan(new RelativeSizeSpan(0.2f), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
editor.setText(text);
在RelativeSizeSpan我已经使用的 0.2F 作为将decrese你TEXTSIZE你可以使用什么都大小您需要accordinglly文字大小
in RelativeSizeSpan i have used 0.2f as a text size which will decrese your textsize you can use what ever size you need accordinglly
这篇关于如何在运行时更改所选文本的字体大小的EditText?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!