android - 椭圆大小在 AutoCompleteTextView 中不起作用

标签 android autocompletetextview

我想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/

相关文章:

android - 在 'java.lang.String.toLowerCase()' 类的 crashlytics 报告中获取空对象引用上的 'com.google.android.gms.internal.zzbsp.zzabx'

java - 安卓 camera2 api 银河 s7

java - Eclipse Translator App - 单独翻译单词 - 不包含前面或后面的字符

android - AutoCompleteTextView with SimpleCursorAdapter for Contacts 不返回光标实际值

android - AutoCompleteTextView - 选择后显示建议

android - phonegap 2.2.0 无法通过 Android 上的 "Device is Ready"屏幕

android - AutoCompleteTextView 中的变音符号/国际字符

android - 如何使 MultiAutoCompleteTextView 搜索子字符串

android - 自动完成 TextView 从 android 中的服务器填充

android - Python 使用 ApkTool 和 Subprocess 反编译 APK