Change the interface of actionSearch, Android

0

I recently implemented the actionSearch in my application, so when you click on the icon, the search bar is displayed. The fact is that I would like to put it in the style of applications such as Twitter or Youtube Gaming (I leave a screenshot below), that is, show a bar instead of the magnifying glass icon.

I have not found information on how to do it, if you could help me or provide a source where I can document to do so I would appreciate it.

Something like this:

Here is the code I used to perform the actionSearch from an icon:

Menu XML code:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_search"
    android:title="@string/action_search"
    android:icon="@drawable/ic_search"
    android:orderInCategory="100"
    app:showAsAction="ifRoom|collapseActionView"
    app:actionViewClass="android.support.v7.widget.SearchView" />

And the java code to implement it:

 public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.videojuegos_menu, menu);
    super.onCreateOptionsMenu(menu,inflater);

    MenuItem searchItem = menu.findItem(R.id.action_search);

    SearchView searchView = (SearchView) searchItem.getActionView();
    searchView.setOnQueryTextListener(this);
}
    
asked by Anto 01.03.2018 в 09:43
source

0 answers