Reputation: 13
I am currently trying to make a Writing program. I would like the functionality of an Edit tool bar that contains things such as BOLD, ITALIC, UNDERLINE, etc. I see that it is under Typeface but I'm struggling to figure out how to make it function on just selected text or just for formatting text. I already have the GUI and button listeners in place. Thanks.
Upvotes: 1
Views: 381
Reputation: 11
Two words my friend, "creative commons". In my experience, mundane pieces of code like date/time pickers, RTF text boxes, etc.. they've all been coded and thought through more thoroughly than you'll ever have the time for. For something like this, don't reinvent the wheel, check out someone else's code, build on it, and check it back in.
Upvotes: 0
Reputation: 1006974
There is nothing really built into Android for this, except at a fairly low level. I have the beginnings of a RichEditText
custom widget, as a drop-in EditText
replacement, but it needs a fair bit of work, which I will get to later in June (I hope I hope I hope).
In a nutshell, you will need to get a Spannable
object from your EditText
via getText()
, then call methods like setSpan()
on it to apply your formatting.
Upvotes: 1