Search code examples
androidsearchview

Android SearchView change cursor position after hint icon


I am using android.support.v7.widget.SearchView and the hint icon is at the left of the cursor as shown in the image .

enter image description here

But i want to make the cursor begins after the hint search icon .

XML:

 <android.support.v7.widget.SearchView
                android:id="@+id/airlines_searchView"
                android:iconifiedByDefault="false"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="15dp"
                android:onClick="EnableSearchView"
                android:background="#fbf7f7"
                />

I got the EditText of the search view as following :

EditText search_text=(EditText) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);

and i don't know what are the required properties to set to it .

I checked That but no solutions found, any help please ?


Solution

  • Have to change the android:iconifiedByDefault to app:iconifiedByDefault

    and add those two lines to avoid launching the keyboard on starting the activity and it is shown only after clicking searchview

    android:focusable="false"
    android:focusableInTouchMode="true"
    

    So Try this:

     <android.support.v7.widget.SearchView
                android:id="@+id/airlines_searchView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:imeOptions="actionDone"
                android:textStyle="normal"
                android:layout_marginTop="15dp"
                android:background="#fbf7f7"
                android:focusable="false"
                android:focusableInTouchMode="true"
                app:iconifiedByDefault="false"/>