我真的堅持這個。我想在片段中使用 CAB,所以我正在使用actionMode = ((MainActivity)getActivity()).startActionMode(actionModeCallbacks);打電話 startActionMode我一直在更改主題并將幾行代碼(一起和分開)添加和測試到 xml 樣式,例如:<item name="android:windowActionModeOverlay">true</item><item name="android:windowActionBarOverlay">true</item><item name="android:windowActionBar">false</item><item name="windowActionBar">false</item><item name="windowActionModeOverlay">true</item><item name="windowActionBarOverlay">true</item>相關(guān)信息:我<include/>在我的主要活動中和里面定義了我的工具欄。工具欄包含在 MainActivity 框架之前,該框架和 DrawerLayout 之間,因此我可以在片段中使用工具欄。我已經(jīng)在 Main Activity 中測試了 CAB,但它也位于工具欄上方。我還嘗試了一個骯臟的解決方法,在創(chuàng)建/銷毀 CAB 時切換工具欄的可見性,但它也不起作用!我正在使用android.view.ActionMode而不是android.support.v7.view.ActionMode因為如果我使用支持庫 (?) , 我將無法調(diào)用 startActionMode。我的工具欄 (*android.support.v7.widget.Toolbar): toolbar = findViewById(R.id.toolbar); mDrawerLayout = findViewById(R.id.drawer_layout); toolbar.setTitle(R.string.addWordLabel_Act); setSupportActionBar(toolbar); toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);XML(工具欄)<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="#FAFAFA" android:theme="@style/AppTheme.NoActionBar" app:collapseIcon="@drawable/ic_arrow_back_white_24dp" app:contentInsetStartWithNavigation="0dp" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" app:title="@string/addWordLabel_Act" app:titleTextColor="@color/colorAccent" />
1 回答

白板的微信
TA貢獻1883條經(jīng)驗 獲得超3個贊
我完全忘記檢查清單,這就是問題所在!AppTheme 設置為“Theme.AppCompat.Light.NoActionBar”而不是“AppTheme”。因此,我在 AppTheme 中所做的任何更改都不會對應用程序生效。
添加回答
舉報
0/150
提交
取消