【问题标题】:search dialog not fully visible - android搜索对话框不完全可见 - android
【发布时间】:2013-01-24 06:33:12
【问题描述】:

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

此外,当我开始打字时,我看不到软键,而当我开始使用电脑键盘打字时,放大图标就会消失。

如果有任何对齐问题,请告诉我?

谢谢

主要活动:

<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>

searchconfig.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>

【问题讨论】:

  • 哦!我注意到一件奇怪的事情,做了一个小的 POC,甚至在我的 Windows 8 笔记本电脑上也有同样的问题。但是,当我将它放在我的 Windows 7 笔记本电脑上时,搜索栏与放大图标(默认搜索图标)一起正确可见。它是特定于机器还是特定于模拟器(两者都是相同的模拟器 - Nexus)

标签: android android-layout android-emulator search-dialog


【解决方案1】:

尝试在菜单项的showAsAction 属性中设置always|collapseActionView。示例:

<item android:id="@+id/search"
      android:title="Search"
      android:icon="@drawable/ic_menu_search"
      android:showAsAction="always|collapseActionView"
      android:actionViewClass="android.widget.SearchView" />

【讨论】:

  • 我没有使用任何菜单项,我只是使用默认的搜索对话框。你能解释一下使用Item view的原因吗?
  • 另外,正如我所说,它在 windows 7 机器上工作正常,但在 windows 8 机器上却不行。它是特定于操作系统/模拟器的还是我真的需要解决这个问题?
猜你喜欢
  • 2011-08-21
  • 1970-01-01
  • 2018-12-08
  • 1970-01-01
  • 2013-09-03
  • 1970-01-01
  • 2012-12-05
  • 2012-01-21
  • 2017-05-11
相关资源
最近更新 更多