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

时间:2014-12-25 08:23:59

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

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

此效果出现在Android 5.0.1和KitKat 4.4.2

在SO上找不到任何解决方案。

当动作模式菜单可见时,如何修复它并仅在工具栏上显示动作模式

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

这是预期的结果 enter image description here

被叫活动布局

<?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"/>

1 个答案:

答案 0 :(得分:2)

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