I am using Toolbar search widget in my project. Everything works fine but expect the thing which I am completely stuck up with removing the underline below search field in m
If you are using SearchView then use for API below 21
android:queryBackground="@android:color/transparent"
you can use below code if you are using API 21 or more
app:queryBackground="@android:color/transparent"
Once try as follows
View v = searchView.findViewById(android.support.v7.appcompat.R.id.search_plate);
v.setBackgroundColor(Color.parseColor("here give actionbar color code"));
Hope this will helps you.
Or you can do this through styles:
<style name="SearchViewMy" parent="Widget.AppCompat.Light.SearchView">
<item name="submitBackground">@color/primaryColor</item>
<item name="queryBackground">@color/primaryColor</item>
</style>
queryBackground is attribute for the query background. If you support voice search you may want to remove the line also under that mic button. Thats what submitBackground attribute is for.
Then of course apply the style to your theme.
<style name="Theme.App" parent="Theme.AppCompat.Light.NoActionBar.FullScreen">
<item name="searchViewStyle">@style/SearchViewMy</item>
</style>
For androidx and kotlin:
menuInflater.inflate(R.menu.conversation_list_screen_menu, menu)
val searchItem = menu.findItem(R.id.action_search)
searchView = searchItem.actionView as SearchView
searchView?.findViewById<View>(androidx.appcompat.R.id.search_plate)?.setBackgroundColor(Color.TRANSPARENT)