0

I have implemented search dialog in my application, the text box is visible at the top and the magnifying icon is visible next to the cursor even though it has complete text box. Ideally magnifying or search icon (default) should have been at the end of the text box.

Also, when I start typing I don't see the softkeys, and as soon as I start typing using the computer keyboard, the magnifying icon goes away.

Can you please let me know if there is any alignment issue?

Thanks

Main Activity:

<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>
Cavish
  • 11
  • 1
  • 5
  • oh! I noticed a strange thing, did a small POC and even that has the same problem in my windows 8 laptop. However when I put it on my windows 7 laptop, the search bar is visible properly along with the magnifying icon (default search icon). Is it specific to machine or specific to emulator (Both are same emulator - Nexus) – Cavish Jan 24 '13 at 15:29

1 Answers1

0

Try to set always|collapseActionView in the showAsAction attribute of your menu item. Example:

<item android:id="@+id/search"
      android:title="Search"
      android:icon="@drawable/ic_menu_search"
      android:showAsAction="always|collapseActionView"
      android:actionViewClass="android.widget.SearchView" />
Timo Ohr
  • 7,947
  • 2
  • 30
  • 20
  • I am not using any menu item, I am just using the default search dialog. Can you please explain the reason behind using Item view? – Cavish Jan 24 '13 at 16:34
  • Also, as I said, its working fine in windows 7 machine but not on windows 8 Machine. Is it specific to OS/emulator or I really need to address this? – Cavish Jan 24 '13 at 16:45