I have a simple layout
as shown below that has a ScrollView
horizontal when it exceeds the limit of TextView
.
But I would like when inserting text the focus of TextView
always stays in the last value entered and does not have to scroll the bar to see the last value inserted.
Type an automatic scroll to follow the entered values.
And go back with the bar manually to start if you need to.
Does anyone have any idea how to do it?
Activity :
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textview = (TextView) findViewById(R.id.textview);
textview.setMovementMethod(new ScrollingMovementMethod());
}
}
xml :
<HorizontalScrollView
android:id="@+id/horizontalScrollView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right">
<TextView
android:id="@+id/display0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:editable="false"
android:gravity="center|right" />
</HorizontalScrollView>
</LinearLayout>