I'm trying to customize my search bar on Android Studio for my application. The result I'd like to achieve is the one here: My Search bar and the Quora's one
I'm trying to follow G's documentation (https://developer.android.com/guide/topics/search/search-dialog.html) without results.
Here's my code:
Styles.xml
<style name="CustomSearchViewStyle" parent="Widget.AppCompat.SearchView">
<item name ="voiceIcon">@drawable/ic_flag</item>
<item name="searchIcon">@drawable/ic_search</item>
<item name="queryBackground">@color/DarkYellow</item>
<item name="android:background">@color/MainYellow</item>
<item name="android:paddingBottom">20dp</item>
<item name="android:paddingTop">5dp</item>
<item name="android:paddingStart">-15dp</item>
<item name="android:paddingEnd">15dp</item>
<item name="android:inputType">textCapWords</item>
</style>
Searchable.xml
<?xml version="1.0" encoding="utf-8"?>
<searchable
xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/app_name"
android:voiceSearchMode="showVoiceSearchButton|launchRecognizer"
/>
MainActivity.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.SearchView
android:id="@+id/top_search_bar"
style="@style/CustomSearchViewStyle"
android:layout_width="match_parent"
android:layout_height="@dimen/search_bar_height"
android:layout_alignParentStart="true"
app:iconifiedByDefault="false"
app:queryHint="@string/search_hint"
android:layout_alignParentEnd="true" />
</RelativeLayout>
Can't get the reason why I can't put a custom icon behind the "Hint Text" nor the voice search icon at the end of the bar, inside the query's field.
I tried to activate this property:
<item name="searchHintIcon">@drawable/ic_search</item>
but nothing happens.
Do you have any suggestions for that?
Thank you so much.
Have a nice day.
UPDATE: Seems that deleting the string "setIconifiedByDefault" in the xml or the java file shows the Hint Icon but I'd like to have my searchBar always NOT iconified (always visible) so, that doesn't solve my issue.