Chris Banes mentioned here that the AppCompat library now has Lollipop's updated SearchView API. I am following the instructions straight from the blog post, but I don't see any effect.
Below is a snippet from my values/styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/color_primary</item>
<item name="searchViewStyle">@style/CustomSearchViewStyle</item>
</style>
<style name="CustomSearchViewStyle" parent="Widget.AppCompat.SearchView">
<item name="queryBackground">@color/orange</item>
<item name="searchIcon">@drawable/test</item>
</style>
Android SearchView provides user interface to search query submitted over search provider. SearchView widget can be implemented over ToolBar/ActionBar or inside a layout. SearchView is by default collapsible and set to be iconified using setIconifiedByDefault(true) method of SearchView class.
To make the SearchView expanded by default, call setIconifiedByDefault(false) on it when you initialise it (e.g. in onCreateOptionsMenu(..) or onPrepareOptionsMenu(..) ). I've found in most cases this will give it focus automatically, but if not simply call requestFocus() on it too.
I was using android.widget.SearchView
instead of android.support.v7.widget.SearchView
. I am guessing that only the android:*
styles work with android.widget.SearchView
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With