I am developing an app like Notepad in which I want to change the selected text formatting dynamically (colors, changing font styles, bold, italic, underline etc.) How can I format a specific word?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
You can get the selected word using
getSelectionStart()
andgetSelectionEnd()
method :Then you can apply your specific formatting by using this selected substring in the full string after taking it to a SpannableStringBuilder on a button click/some other event:
Code for formatting text:
Reference.
Hope this code suits yours case