I have some problem when I try to display my SearchView.
What I need:
1.Make SearchView always opened without any close buttons.
2.Display another icon after Searchview
My code:
menu_fragment_xml:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".CardBaseFragment">
<item android:id="@+id/action_search"
android:title="Search"
style="@style/SearchViewStyle"
app:showAsAction="ifRoom|collapseActionView"
app:actionViewClass="android.support.v7.widget.SearchView"
/>
<item android:id="@+id/сhange_country"
android:title="@string/add_new_card"
app:showAsAction="always"
android:actionBarWidgetTheme="@style/myStyle"
android:icon="@drawable/ic_change_country">
</item>
</menu>
style:
<style name="SearchViewStyle" parent="Widget.AppCompat.SearchView">
<!-- Gets rid of the "underline" in the text -->
<item name="queryBackground">@null</item>
<!-- Gets rid of the search icon when the SearchView is expanded -->
<item name="searchHintIcon">@null</item>
<!-- The hint text that appears when the user has not typed anything -->
<item name="queryHint">Test</item>
</style>
Now, when program starts , everything is ok, but still I have back button.
When I change SearchView app:showAsAction="ifRoom|collapseActionView"
to "always"
, SearchView overlap my second item, how can I remove back button correctly, without creating new layout for toolbar?
((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
Didn't help.