4

Here is what my SearchView looks like using Android Support Library version 23.0.4:

enter image description here

And here is what it looks like using Support Library 24.0.0:

enter image description here

How can I get my SearchView to properly show text in 24.0.0? This is not a text color issue FYI, I have adjusted text color of the EditText to no avail. You can also see it is missing the "x" button on the right.

Update

Here is the XML I am using for my search menu:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/search"
        android:icon="@drawable/nav_icon_search"
        android:title="@string/search"
        app:actionViewClass="android.support.v7.widget.SearchView"
        app:showAsAction="ifRoom|collapseActionView" />
</menu>

Here is the code I am using in my onCreateOptionsMenu:

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.menu_location_list, menu);
    this.configureSearchView(menu);
    super.onCreateOptionsMenu(menu, inflater);
}

private void configureSearchView(Menu menu) {
    MenuItem search = menu.findItem(R.id.search);
    MenuItemCompat.setOnActionExpandListener(search, this);

    this.mSearchView = (SearchView)   
    MenuItemCompat.getActionView(search);
    this.mSearchView.setOnQueryTextListener(this);
    this.mSearchView.setOnCloseListener(this);
    this.mSearchView.setSubmitButtonEnabled(false);
    this.mSearchView.setIconifiedByDefault(true);

    this.mSearchMenuItem = search;
}
Community
  • 1
  • 1
esilver
  • 27,713
  • 23
  • 122
  • 168
  • Did you set the text color to white ?? – Rakshit Nawani Jul 01 '16 at 17:19
  • I set the text color to every possible iteration including white. No avail. It's not just the text color; there is an initial icon that is not visible too (prior to entering text). – esilver Jul 01 '16 at 17:56
  • @esilver could you share the xml for your search menu, as well as your onCreateOptionsMenu() method? – Dr. Nitpick Jul 01 '16 at 22:56
  • @Dr.Nitpick Shared – esilver Jul 02 '16 at 17:43
  • Man, I am confused as to why this is not working. I tried out the code you shared on an app compiled against sdk 24, build tools 24 and support lib 24 and it worked just fine. I did have to coment out the line where you set your activity as the `OnActionExpandListener` but that was it. It may work correctly if you comment it out as well? Are you doing anything in `onMenuItemActionExpand` that would prevent the search view from expanding properly? – Dr. Nitpick Jul 03 '16 at 04:45
  • Besides what I said above, I am not sure I can give you any helpful input without seeing your project code, and that seems like a heavy handed approach. I'm sorry mate, if I think of anything else I will let you know. – Dr. Nitpick Jul 03 '16 at 04:46
  • Did you tried this solution: https://stackoverflow.com/a/38048481/2498248 ? – Alex Jul 04 '16 at 09:13
  • 1
    @Alex that solved it! though I used the height android:layout_height="?android:attr/actionBarSize" instead. – esilver Jul 05 '16 at 04:16

0 Answers0