android - 当 ActionMode 打开时,AppCompat 工具栏保持可见

标签 android android-appcompat drawerlayout android-toolbar android-actionmode

我的应用程序包含一个 DrawerLayout,并在其中包含 appcompat 工具栏。 当抽屉“打开” fragment 时,一切正常,但是当我从 fragment 开始一个 Activity ,然后它显示操作模式菜单时,它们显示在工具栏顶部,但我希望它以与 fragment 工作相同的方式显示在工具栏上。

此效果存在于 Android 5.0.1 和 KitKat 4.4.2 上

在 SO 上找不到对我有用的解决方案。

如何修复此问题,并在操作模式菜单可见时仅在工具栏上显示操作模式?

下图显示了错误的结果 ActionMode and Toolbar

这是预期的结果 enter image description here

被调用的activity布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <include layout="@layout/toolbar_app"/>
    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</LinearLayout>

工具栏布局

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
                                   xmlns:app="http://schemas.android.com/apk/res-auto"
                                   android:id="@+id/my_toolbar"
                                   android:layout_height="wrap_content"
                                   android:layout_width="match_parent"
                                   android:minHeight="?attr/actionBarSize"
                                   app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
                                   app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                                   android:background="?attr/colorPrimary"/>

最佳答案

添加<item name="windowActionModeOverlay">true</item>样式将解决问题

关于android - 当 ActionMode 打开时,AppCompat 工具栏保持可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27645501/

相关文章:

android - DDMS 不显示我的日志

android - 如何使用水平滚动创建 Recycler Grid View

android - 本地 aar 库的传递依赖

android - 无法在 Android 上使用 appcompat 更改 TextView 的颜色

android - Lollipop 之前的设备中未出现工具栏

android - 如何防止其他应用程序定义相同的权限名称

android - getActionBar() 在 api 19 中返回 null,目标是 api 21 min sdk 16

android - 如何将 NavigationView 与标准 Android 主题一起使用?

android - 工具栏菜单项总是溢出

android - 从左向右滑动时,无论在哪里,如何显示DrawerLayout?