0

我在我的应用程序中实现了搜索对话框,文本框在顶部可见,放大图标在光标旁边可见,即使它有完整的文本框。理想情况下,放大或搜索图标(默认)应该位于文本框的末尾。

此外,当我开始键入时,我看不到软键,并且一旦我开始使用计算机键盘键入,放大图标就会消失。

如果有任何对齐问题,您能告诉我吗?

谢谢

主要活动:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="Hello" />

</RelativeLayout>

搜索配置.xml

<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
    android:label="@string/app_name" 
    android:hint="true"
    >

</searchable>
4

1 回答 1

0

尝试设置菜单项always|collapseActionViewshowAsAction属性。例子:

<item android:id="@+id/search"
      android:title="Search"
      android:icon="@drawable/ic_menu_search"
      android:showAsAction="always|collapseActionView"
      android:actionViewClass="android.widget.SearchView" />
于 2013-01-24T15:37:58.837 回答