在工具栏上显示 ActionMode [英] Display ActionMode over Toolbar

查看:32
本文介绍了在工具栏上显示 ActionMode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除了传统的 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 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;

而不是

import android.view.ActionMode;

然后使用

_actionMode = startSupportActionMode(this);

而不是

_actionMode = startActionMode(this);

这篇关于在工具栏上显示 ActionMode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆