How to make the Contextual ActionMode Bar overlay the appcompat-v7 Toolbar but not the navigation drawer?

我的梦境 提交于 2019-11-30 00:04:26

I might have found a solution - or perhaps a simple workaround.
I had the same problem even with a ListFragment, when startActionMode() was used instead of the built-in setChoiceMode(). So I looked into ListFragment code and I found that startActionMode() is not called on the activity but rather on its ListView, so I've tried using a view. In my code now it apparently works as expected using either the fragment ListView:

ActionMode mActionMode = getListView().startActionMode(this);

or using the Activity container that contains my fragment:

View aView = getActivity().findViewById(R.id.container);
ActionMode mActionMode = aView.startActionMode(this);

Also:

  • now the back button destroys the action mode whilst before it didn't
  • the CAB now properly covers the Action Bar, whilst using windowActionModeOverlay in my style was covering only part of it - at least in my case
  • the CAB icon is a back arrow rather than a tick - not sure what this means though

To be honest I'm not sure about the reasons behind this, so I'm not sure how safe this solutions is, however for the time being seems to work fine.
Should anyone have a better understanding please feel free to comment or edit.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!