更新时间:2021-12-28 06:13:04
如果用户尝试轻按edittext来移动光标,则以下代码将强制光标停留在最后位置:
Following code will force the curser to stay in last position if the user tries to move it with a tap on the edittext:
edittext.setCursorVisible(false);
edittext.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
edittext.setSelection(edittext.getText().length());
}
});
请注意,用户仍然可以通过箭头键和/或轨迹球更改光标的位置.据我所知,目前没有解决此问题的方法.
Note that the user can still change the position of the curser via arrow keys and / or trackball. As far as I know there is currently no workaround for this issue.