Action Bar Icon hidden after SearchView expands

后端 未结 2 671
时光说笑
时光说笑 2021-02-13 11:32

\"When

\"When<

相关标签:
2条回答
  • 2021-02-13 12:26

    try with this, works for me using appCompat v21

    final MenuItem switchButton = menu.findItem(R.id.action_import);
    final MenuItem searchItem = menu.findItem(R.id.action_search);
    
    MenuItemCompat.setShowAsAction(searchItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
    MenuItemCompat.setShowAsAction(switchButton, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); 
    
    0 讨论(0)
  • 2021-02-13 12:39

    What I have done for a situation like this is using a toolbar in xml while setting the theme to be NO_ACTION_BAR. Then in the toolbar (in my layout.xml file) I put a RelativeLayout. Using the leftOf=@id/someButton you should be able to keep all the buttons visible at all times.

    0 讨论(0)
提交回复
热议问题