我想android:ellipsize
AutoCompleteTextView
中的文本。尝试了以下代码,但它不起作用。
有人可以帮助我吗?
代码如下:
<AutoCompleteTextView
android:id="@+id/address_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:completionThreshold="3"
android:imeOptions="actionSearch"
android:imeActionLabel="Search"
android:textSize="16sp"
android:singleLine="true"
android:ellipsize="end" />
最佳答案
我认为AutocompleteTextView对于ellipSize是不可行的,但是我们可以设置ellipsize自定义,下面是代码,
String fullText = "Give your text here";
int width = autocompleteTextview.getMeasuredWidth() - (autocompleteTextview.getPaddingLeft()+autocompleteTextview.getPaddingRight());
String truncatedText = TextUtils.ellipsize(mFullText, autocompleteTextview.getPaint(), width, TextUtils.TruncateAt.END).toString();
if(truncatedText!=null&& truncatedText.length()>0){
autocompleteTextview.setText(truncatedText);
}
关于android - 椭圆大小在 AutoCompleteTextView 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18864215/