How to display cursor at the end of text in TextView?

前端 未结 4 1183
一整个雨季
一整个雨季 2021-02-09 18:51

I wanted to display blinking cursor at the end of the text in TextView .

I tried by android:cursorVisible=\"true\" in TextView But no go .

Even i t

4条回答
  •  星月不相逢
    2021-02-09 18:58

    First of all you should use EditText in place of TextView for taking input. If still the cursor doesn't blink, set the android:cursorVisible="true"attribute in xml file, it should make the cursor blink. If your cursor is not visible in edit text, that's also a reason one can't see the cursor blinking. Set android:textCursorDrawable="@null". This should solve your problem

    
    
    
    

    In your activity class, add this code as well.

    EditText input = (EditText)findViewById(R.id.edittext1);
    input.setSelection(input.getText().length());
    

提交回复
热议问题