Text editor options with Kotlin

Viewed 18

I was wondering how to make a text editor toolbar for an android app using Kotlin.

I've already implemented the view as you can see here. But I can't find a way to make it work propperly. I've tried to use Spannable String and Typeface but I think that they are not what I am looking for.

When using spannable, I need to put some string. But I can't put a string because there may be no text yet.

Maybe using the textchange listener of the EditText would work? I've tried it too but it doesn't seem to fit into my logic.

This is what I was thinking about: A listener for every button. Whenever a button is pressed, add that style to the future text that will come. To specify the start and the end of the text, maybe I could take the current position of the cursor to specify the start and the position of the cursor whenever the button is "unpressed" to specify the end. But I can't find something that fits my logic.

Maybe you could give me some ideas, another logic...Which is the proper way to do it?

Thank you very much :)

0 Answers
Related