首先,您需要获取光标所在的行索引。我包括该代码,但您可以在此处看到它。val lineIndex = getCursorLinePosition( editText ) val startPos = editText.layout.getLineStart( lineIndex )// for beginning for a lineeditText.setSelection( startPos )val endPos = editText.layout.getLineEnd( lineIndex )// for end of the lineeditText.setSelection( endPos )