我的应用程序包含一个 DrawerLayout,并在其中包含 appcompat 工具栏。 当抽屉“打开” fragment 时,一切正常,但是当我从 fragment 开始一个 Activity ,然后它显示操作模式菜单时,它们显示在工具栏顶部,但我希望它以与 fragment 工作相同的方式显示在工具栏上。
此效果存在于 Android 5.0.1 和 KitKat 4.4.2 上
在 SO 上找不到对我有用的解决方案。
如何修复此问题,并在操作模式菜单可见时仅在工具栏上显示操作模式?
下图显示了错误的结果
这是预期的结果
被调用的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/