在工具栏上显示 ActionMode [英] Display ActionMode over Toolbar
问题描述
除了传统的 android 之外,我还尝试将
.我可以显示它:android.view.ActionMode
与新的 android.support.v7.widget.Toolbar
一起使用.app.ActionBar
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);
问题是 ActionMode
显示在 ActionBar
上,而不是 Toolbar
上.有什么办法可以改变吗?
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>
推荐答案
由于您使用的是
Toolbar
,我还假设您使用的是AppCompatActivity
并将内置的ActionBar
替换为您的自定义Toolbar
使用setSupportActionBar(toolbar);
Since you are using the
Toolbar
, I also assume you are using theAppCompatActivity
and have replaced the built inActionBar
with your customToolbar
usingsetSupportActionBar(toolbar);
首先确保您导入了正确的命名空间:
First of all ensure you are importing the correct namespace:
import androidx.appcompat.view.ActionMode;
// Or
import android.support.v7.view.ActionMode;
而不是
import android.view.ActionMode;
然后使用
_actionMode = startSupportActionMode(this);
而不是
_actionMode = startActionMode(this);
这篇关于在工具栏上显示 ActionMode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!