在Android上如何在SearchView中换行提示文本

3

我需要将写在 SearchView 内部的提示文本进行包装。我该如何实现?

使用下面的代码,文本显示为:"This is a very lo..."

这是我的 SearchView

<SearchView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/sv"
        android:queryHint="This is a very long searchview hint"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" />

编辑

我能够通过编程方式完成这个操作:

int id = mSvBusqueda.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
EditText editText = (EditText) mSvBusqueda.findViewById(id);
editText.setSingleLine(false);

但是我无法让搜索视图容器包裹编辑文本(见图片)

Searchview not wrapping content

2个回答

0

地址:

android:lines="1"

现在要禁用 "Enter":

EDIT_TEXT.setOnKeyListener(new OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event)
        {
            if (keyCode == KeyEvent.KEYCODE_ENTER)
            {
                return true;
            }
            return false;
        }
    });

如何在单行AutoCompleteTextView中换行提示?


"lines" 不是 SearchView 的属性。而且我并没有使用 EditText,我正在使用 SearchView。 - IIRed-DeathII

0

尝试使用 android:ellipsize="end"


不行,这个不起作用。顺便说一下,SearchView中似乎没有ellipsize属性。 - IIRed-DeathII

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接