Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

customize the androidx.appcompat.widget.SearchView site:stackoverflow.com

SearchView mSearchView = (SearchView)menu.findItem(R.id.search).getActionView();
    try
    {
        Field searchField = SearchView.class.getDeclaredField("mSearchButton");
        searchField.setAccessible(true);
        ImageView searchBtn = (ImageView)searchField.get(mSearchView);
        searchBtn.setImageResource(R.drawable.search_img);
        searchField = SearchView.class.getDeclaredField("mSearchPlate");
        searchField.setAccessible(true);
        LinearLayout searchPlate = (LinearLayout)searchField.get(mSearchView);
        ((ImageView)searchPlate.getChildAt(0)).setImageResource(R.drawable.search_img);
        searchPlate.setBackgroundResource(R.drawable.edit_text_bkg);
    }
    catch (NoSuchFieldException e)
    {
        Log.e(TAG,e.getMessage(),e);
    }
    catch (IllegalAccessException e)
    {
        Log.e(TAG,e.getMessage(),e);
    }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #customize
ADD COMMENT
Topic
Name
5+8 =