0

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.

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 ?

Raneez Ahmed
  • 3,808
  • 3
  • 35
  • 58
  • 1
    Check http://stackoverflow.com/questions/3241729/android-dynamically-change-style-at-runtime – Zain Ali Jul 21 '12 at 06:31
  • possible duplicate of [How to set font style of selected text using custom typeface through spannable method](http://stackoverflow.com/questions/8710300/how-to-set-font-style-of-selected-text-using-custom-typeface-through-spannable-m) – KV Prajapati Jul 21 '12 at 06:54

1 Answers1

3

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

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

Khan
  • 7,585
  • 3
  • 27
  • 44