显示ActionMode在工具栏工具栏、ActionMode

2023-09-05 08:24:17 作者:一起去小卖部吗

我试图使用 android.view.ActionMode android.support.v7.widget.Toolbar ,除了传统的 android.app.ActionBar 。我能够与显示它:

  toolbar.startActionMode(回调);
 

的问题是, ActionMode 显示在动作条,而不是在工具栏。有没有办法来改变这种状况?

我tryied设置在我的主题下,但它似乎并没有改变什么:

 <项目名称=windowActionModeOverlay>真< /项目>
 

解决方案   

由于您使用的是工具栏,我还以为你正在使用    AppCompatActivity 键,取代了内置的动作条与   您的自定义工具栏使用 setSupportActionBar(工具栏);

首先确保您输入正确的名称空间。

 进口android.support.v7.view.ActionMode;
 
Avocode电脑端官方2021最新版免费下载

和不

 进口android.view.ActionMode;
 

然后用

  _actionMode = startSupportActionMode(本);
 

和不

  _actionMode = startActionMode(本);
 

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>

解决方案

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 android.support.v7.view.ActionMode;

and NOT

import android.view.ActionMode;

then use

_actionMode = startSupportActionMode(this);

and NOT

_actionMode = startActionMode(this);