2013-01-24 25 views
0

我已經在我的應用程序中實現了搜索對話框,文本框在頂部可見,放大圖標在光標旁邊可見,即使它具有完整的文本框。理想情況下,放大或搜索圖標(默認)應該在文本框的末尾。搜索對話框不完全可見 - android

此外,當我開始輸入時,我沒有看到軟鍵,只要我開始使用電腦鍵盤輸入,放大圖標就會消失。

您能否讓我知道是否有任何對齊問題?

感謝

主要活動:

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

哦!我注意到一個奇怪的事情,做了一個小的POC,甚至在我的Windows 8筆記本電腦上也有同樣的問題。但是,當我將它放在Windows 7筆記本電腦上時,搜索欄與放大圖標(默認搜索圖標)一起正常可見。 它是特定於機器還是特定於仿真器(兩者都是相同的仿真器 - Nexus) – Cavish

回答

0

嘗試設置always|collapseActionView在你的菜單項的showAsAction屬性。例如:

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

我沒有使用任何菜單項,我只是使用默認的搜索對話框。你能解釋一下使用Item視圖的原因嗎? – Cavish

+0

另外,正如我所說的,它在Windows 7機器上工作正常,但不在Windows 8機器上工作。它是特定於OS /模擬器還是我真的需要解決這個問題? – Cavish