How to change the color of the bottom line underneath a SearchView

Shane Monks O'Byrne :

Pretty straight-forward, how do I change the color of the line along the bottom of a SearchView in Android? I've tried, queryBackground, background, and various other things but cant seem to get it in XML. Im happy doing it programmatically or in XML. Just want it to work!

CheersSearchView example

Chetan Joshi :

Use Below method to change colour of bottom line of SearchView.

Here I add Blue Colour as bottom Line

private void customizeSearchView() {
        int searchTextId = getResources().getIdentifier("android:id/search_src_text", null, null);
        EditText searchBox = ((EditText) searchView.findViewById(searchTextId));
        searchBox.setBackgroundColor(Color.WHITE);
        searchBox.getLayoutParams().height = LinearLayout.LayoutParams.MATCH_PARENT;
        int search_plateId = getResources().getIdentifier("android:id/search_plate", null, null);
        View mSearchPlate = ((View) searchView.findViewById(search_plateId));
        mSearchPlate.setBackgroundColor(Color.BLUE);

        int searchCloseImageId = getResources().getIdentifier("android:id/search_close_btn", null, null);
        ImageView searchClose = ((ImageView) searchView.findViewById(searchCloseImageId));// change color
        searchClose.setBackgroundColor(Color.WHITE);
    }

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=160270&siteId=1