【问题标题】:AppCompat Toolbar stays visible when ActionMode is on当 ActionMode 打开时,AppCompat 工具栏保持可见
【发布时间】:2014-12-25 18:32:59
【问题描述】:

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

Android 5.0.1 和 KitKat 4.4.2 上存在此效果

在 SO 上没有找到适合我的解决方案。

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

下图显示了错误的结果

这是预期的结果

被调用的活动布局

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

【问题讨论】:

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


    【解决方案1】:

    在样式中添加&lt;item name="windowActionModeOverlay"&gt;true&lt;/item&gt; 将解决问题

    【讨论】:

    • 这已经存在于主题定义中,并且确实适用于片段,我的问题与从片段开始的活动有关
    • @dafi 我面临着完全相同的问题。我在样式中提到了 windowAcitonModeOverlay。你能告诉我,你是如何解决这个问题的吗?
    猜你喜欢
    • 2016-06-18
    • 2015-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-16
    • 1970-01-01
    相关资源
    最近更新 更多