Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display ActionMode over Toolbar

I am trying to use the android.view.ActionMode with the new android.support.v7.widget.Toolbar, in addition to the traditional android.app.ActionBar. I am able to display it with:

toolbar.startActionMode(callback); 

The problem is that the ActionMode is displayed over the ActionBar, and not over the Toolbar. Is there a way to change that?

I tryied to set the following in my theme, but it does not seem to change anything:

<item name="windowActionModeOverlay">true</item> 
like image 733
Gaëtan Avatar asked Oct 21 '14 09:10

Gaëtan


1 Answers

Since you are using the Toolbar, I also assume you are using the AppCompatActivity and have replaced the built in ActionBar with your custom Toolbar using setSupportActionBar(toolbar);

First of all ensure you are importing the correct namespace:

import androidx.appcompat.view.ActionMode; // Or import android.support.v7.view.ActionMode; 

and NOT

import android.view.ActionMode; 

then use

_actionMode = startSupportActionMode(this); 

and NOT

_actionMode = startActionMode(this); 
like image 120
Kuffs Avatar answered Sep 23 '22 01:09

Kuffs