Skip to content Skip to sidebar Skip to footer

Set Cursor Position In Edittext According To User Click

I want the cursor to follow user click to edit existing text in the editText. To disable action bar of editing in tablet i use: edittext.setCustomSelectionActionModeCallback(new A

Solution 1:

Layout layout = ((EditText) v).getLayout();
float x = event.getX() + edittext.getScrollX();
int offset = layout.getOffsetForHorizontal(0, x); 
edittext.setSelection(offset); 

Post a Comment for "Set Cursor Position In Edittext According To User Click"