Display ActionMode over Toolbar

后端 未结 9 1787
臣服心动
臣服心动 2020-12-02 09:59

I am trying to use the android.view.ActionMode with the new android.support.v7.widget.Toolbar, in addition to the traditional android.app.Act

9条回答
  •  广开言路
    2020-12-02 10:54

    I have tried all the methods above, but it still doesn`t work. And then, I tried the below method:

        private class ActionModeCallback implements ActionMode.Callback {
        @Override
        public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
            actionMode.getMenuInflater().inflate(R.menu.note_find_action, menu);
            return true;
        }
    
        @Override
        public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
            ((AppCompatActivity) getActivity()).getSupportActionBar().hide();
            return false;
        }
    
        @Override
        public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
            return false;
        }
    
        @Override
        public void onDestroyActionMode(ActionMode actionMode) {
            ((AppCompatActivity) getActivity()).getSupportActionBar().show();
        }
    }
    

    Here, I used action mode and startSupportActionMode method of support library. At the same time I have also tried to modify the theme of given activity. Surely, it doesn`t work. So, if you really have no better choice you may try this one.

    Just recently, I have found that I used the Colorful frame to enable multiple theme of my app, this will change the theme in code. When I tried to modify the style in this framework, it works.

    Hope it works.

提交回复
热议问题