如果我将SearchView查询设置为比框长的字符串,如何使它成为可见的字符串的第一部分而不是最后一部分?(我将其用作WebView的导航/搜索栏。)
我做
mySearchView.setQuery("Start of long string.... at the end.", false);
并希望它显示
Start of long
代替
at the end
它总是告诉我结局。实际上,我希望它回滚到文本的开头。
编辑:我确实希望完整的文本在那里,只是滚动到开始。
如果我记得很清楚,你需要获得的保持EditText
在SearchView
再设置ellipsize就可以了。
int id = mySearchView.getContext()
.getResources()
.getIdentifier("android:id/search_src_text", null, null);
EditText editText = (EditText) mySearchView.findViewById(id);
editText.setEllipsize(TextUtils.TruncateAt.END);
如果您不想放大,可以使用相同的方法并在EditText中设置位置。
int id = mySearchView.getContext()
.getResources()
.getIdentifier("android:id/search_src_text", null, null);
EditText editText = (EditText) mySearchView.findViewById(id);
editText.setSelection(0);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句