A
A
AndroidApi2017-03-02 14:03:03
Android
AndroidApi, 2017-03-02 14:03:03

Remove icon from SearchView?

4e9437c5bbf946d2999e5a361f1a96a2.pngDo not tell me how to remove the search icon on the left when android.support.v7.widget.SearchView is active.

<item
        android:id="@+id/action_search"
        android:title="@android:string/search_go"
        app:showAsAction="always"
        app:actionViewClass="android.support.v7.widget.SearchView" />

private void initToolBar() {
        toolbar = (Toolbar) findViewById(R.id.toolbarSearch);
        setSupportActionBar(toolbar);

        toolbar.setNavigationIcon(R.mipmap.ic_arrow_back_white_24dp);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });


        //toolbar.inflateMenu(R.menu.search_menu);
    }


 @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);

        getMenuInflater().inflate(R.menu.search_menu, menu);

        SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
        searchView.clearFocus();
        searchView.setIconifiedByDefault(false);
        return true;
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question