How to keep expanded SearchView on the right side of ActionBar (while using custom icon)?

前端 未结 3 787
梦谈多话
梦谈多话 2020-12-18 01:15

My question is closely related to SearchView wrong alignment and SearchView positions when expanded in ActionBar but the answers posted there do not work.

So, I\'m u

3条回答
  •  爱一瞬间的悲伤
    2020-12-18 02:00

    Using this worked for me:

    final SearchView searchView = (SearchView) searchMenuItem.getActionView();
    searchView.setOnSearchClickListener(new View.OnClickListener()
    {
         @Override
         public void onClick(View v)
         {
             searchView.setLayoutParams(new Toolbar.LayoutParams(Gravity.END));
         }
    });
    

提交回复
热议问题