Reputation: 73
I use EditText
with option scrollbars=vertical
to write my data in my app.
The problem is when I received data my scrollbar automatically goes down.
I would like to prevent automatic scrolling when I press the screen
<EditText
android:id="@+id/edCapteur"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#9CE49C"
android:focusable="false"
android:scrollbars="vertical"
/>
I use this for add data in my edidtext:
edidtext.append("data");
Upvotes: 0
Views: 60
Reputation: 2348
This is because the cursor of edittext
is moved to the end. You need to keep the cursor at its original position
int originalPosition = edidtext.getSelectionStart();
edidtext.append("data");
edidtext.setSelection(originalPosition);
Upvotes: 1