Darkchili Slayer Darkchili Slayer - 23 days ago 10
Android Question

Allow user to set part of multiline textbox bold

I have a multi line text box in android SDK and I want to make a bar where the user can click bold/italic buttons and either the selected area in the multiline will become bold/italic OR the text the user types will be bold until the user deselects bold/italic.

Is this possible? If so can someone gives some sample code. I am new to programming in android so this is difficult.

EDIT: Changing font size and font is an extra but will be good if possible.
EDIT: Forgot to say using android 5.0, not that it makes too much of a difference.

Answer

Yes ,you can set the text style and font by using a method just use if else statement in the method and pass an integer

if(i==0){
textView.setTypeface(null, Typeface.BOLD);
 }
else if(i==1){
textView.setTypeface(null, Typeface.ITALIC);}

You can do some thing like this it's not the complete as I write from my mind. hope it will help ,And in the similar way you can set the text size also.

Comments