In my app, I have an EditText where the user can select a part of the text. The problem is that the selection behavior is different depending on the phone : with one, the user can select normally, but with another one the user must tap on the text indicator and then tap on "Select All".
How can I set the behavior like the first one as default ? And why the behavior is different between phones ?
Thank you for your answers, have a nice day !
EDIT :
Now I select the word which contains the cursor with this method :
fun EditText.selectCurrentWord() {
val textSpan = text
val selection = selectionStart
val pattern = Pattern.compile("\\w+")
val matcher = pattern.matcher(textSpan)
var start: Int
var end: Int
while (matcher.find()) {
start = matcher.start()
end = matcher.end()
if (selection in start..end) {
setSelection(start, end)
break
}
}
}
But now the problem is that cursors at the start and end of selection doesn't appear...
The EditText is selectable and isCursorVisible
is set to true.