For some reason my searchview has a white background instead of transparent and I cant seem to get rid of it. I am using AppCompat theme. I am using a ToolBar
manually as my ActionBar
.
menu.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/search"
android:title="Search"
android:icon="@android:drawable/ic_menu_search"
app:showAsAction="collapseActionView|ifRoom"
app:actionViewClass="com.exposure.controls.ExposureSearchView" />
</menu>
<style name="LaunchTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:colorBackground">@color/app_background</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:background">@android:color/transparent</item>
<item name="windowActionBarOverlay">true</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowFullscreen">true</item>
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="searchViewStyle">@style/MySearchViewStyle</item>
</style>
<style name="MySearchViewStyle" parent="Widget.AppCompat.SearchView">
<item name="queryBackground">@android:color/transparent</item>
<item name="submitBackground">@android:color/transparent</item>
</style>
Change the text colors and icons of searchview in action bar. Expand the search view by setting iconified and iconifiedByDefault flags to false. Find views inside the search view and set the colors as per your wish. Find views of the icons you wish to change and replace them with your icons.
To set Android Button background color, we can assign android:backgroundTint XML attribute for Button in layout file with the required Color Value. To programmatically set or change Android Button background color, we may call pass the method Button.
androidx.appcompat.widget.SearchView. A widget that provides a user interface for the user to enter a search query and submit a request to a search provider.
I updated these backgrounds to transparent and it worked.
<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="android:background" tools:ignore="NewApi">@android:color/transparent</item>
<item name="background">@android:color/transparent</item>
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