The Android EditText cursor is displayed at the end of the question.

demand

  1. EditText does not automatically gain focus (no cursor display) when entering the page
  2. when you click on the EditText area for the first time, the cursor appears at the end, and a soft keyboard appears
  3. Click EditText for the second time to specify the location, the cursor moves to the specified location, and the user edits

Code

  • layout

    
    <EditText android:background="@null" />
    
</RelativeLayout>

effect

  • implements requirements: 1
  • the first time you click on the EditText area, the keyboard displays, but the cursor position is where the user clicked, not at the end, unless the user clicks at the end.

question

  • how to implement requirements: 2
Mar.14,2021

problem has been solved

the key point of this question is the timing of the setSelection () method

Let's talk about how to solve it first

  • you don't need to make any extra settings in the layout
  

EditText has a setSelection method that should meet your needs

Menu