javaandroidsearchview

android searchView background when cursor is focused and moving hides the text behind a white box


im using a SearchView in my android activity.
the SearchView is defined in the activity menu.xml like so:

<item
        android:id="@+id/action_search"
        android:icon="@drawable/ic_search_white_48dp_action"
        android:title="@string/Search"
        android:visible="true"
        android:background="@android:color/transparent"
        app:queryBackground="@android:color/transparent"
        app:submitBackground="@android:color/transparent"
        app:actionViewClass="androidx.appcompat.widget.SearchView"
        app:showAsAction="always|collapseActionView" />

in the code its used like this:

MenuItem searchItem = menu.findItem(R.id.action_search);
SearchView filterPartsSearchView = (SearchView) searchItem.getActionView();
filterPartsSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
filterPartsSearchView.setBackgroundColor(ResourcesCompat.getColor(getResources(), R.color.transparent, null));

this is how it looks when i click the text and start moving it around:

image of the issue

how can i remove that white box?

i tried setting the color as transparent in menu.xml and in the activity


Solution

  • Seems that i found a solution. i edited my toolbar style from this

    <style name="ToolBarStyle" parent="Theme.AppCompat">
            <item name="android:textColorPrimary">@color/white</item>
            <item name="android:textColorSecondary">@color/white</item>
            <item name="android:background">@color/colorPrimary</item>
            <item name="android:popupBackground">@color/white</item>
        </style>
    

    to this

        <style name="ToolBarStyle" parent="Theme.AppCompat">
            <item name="android:textColorPrimary">@color/white</item>
            <item name="android:textColorSecondary">@color/white</item>
            <item name="android:background">@color/colorPrimary</item>
    <!--        <item name="android:popupBackground">@color/white</item>-->
        </style>
    

    and it worked. not sure if anything else will be affected by removing the popupBackground property but for now its enough