SearchView not showing queryHint text

VIN picture VIN · Aug 25, 2016 · Viewed 8.6k times · Source

I have a search view with a background drawable, but I can't seem to get the text to appear no matter what I try. No text shows up in the SearchView.

I've tried the android:text and android:queryHint and even setting it programmatically using mSearchView.setQueryHintText("search for something"); but none of these work. The searchView is not inside an actionBar.

Here is the xml for the searchview

<android.support.v7.widget.SearchView
        android:id="@+id/m_search_view"
        android:layout_width="match_parent"
        android:layout_height="@dimen/searchbar_height"
        android:layout_alignWithParentIfMissing="true"
        android:layout_toLeftOf="@+id/other_button"
        android:background="@drawable/rounded_corner_box"
        android:focusableInTouchMode="true"
        android:gravity="center_vertical|left"
        android:paddingLeft="@dimen/left_padding"
        android:queryHint="search for something"
        android:textAppearance="@style/m_text_appearance"
        android:textColor="@color/m_text_color" />

When I don't set a background, I don't see the searchView at all (the searchView is translucent).

Any help would be appreciated.

Answer

WiseTap picture WiseTap · Jun 10, 2017
searchView.setIconified(false);