【发布时间】:2015-03-22 23:30:24
【问题描述】:
我知道有几个关于操作栏的上下文操作栏 (ActionMode) 部分的样式的问题,但它们似乎并没有完全解决我所追求的问题。
我正在使用带有浅色主题和深色操作栏的工具栏。工具栏看起来像我想要的,但动作模式看起来像常规的深色主题。我需要改变我的风格以获得黑暗主题的动作模式(不仅仅是动作栏)?看来我应该能够通过点击Theme.AppCompat 快速做到这一点,因为这向 CAB 显示了我想要的方式,但我不希望应用程序的其余部分变暗。
我只关心 API 14+,我使用支持工具栏代替操作栏。
这是我的基本风格
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="android:actionModeBackground">@color/colorActionMode</item>
<item name="android:windowActionModeOverlay">true</item>
</style>
工具栏样式
<style name="AppTheme.Toolbar" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:textColorPrimary">@color/abc_primary_text_material_dark</item>
<item name="actionMenuTextColor">@color/abc_primary_text_material_dark</item>
<item name="android:textColorSecondary">@color/abc_primary_text_material_dark</item>
<item name="android:background">@color/colorPrimaryDark</item>
</style>
工具栏布局文件(这里设置popupTheme好像没有任何效果)。
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
app:theme="@style/AppTheme.Toolbar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark"
android:popupTheme="@style/ThemeOverlay.AppCompat.Dark"
android:elevation="2dp"
android:focusable="false"/>
这是我的工具栏(这是我想要的)
这是我的 ActionMode(我需要反转)
这就是我希望 ActionMode 看起来的样子(我通过将样式更改为从 Theme.AppCompat 继承而不是 Theme.AppCompat.Light.DarkActionBar 得到。问题是应用程序的其余部分变暗了,这是我不想要的.
【问题讨论】:
标签: android android-actionbar android-toolbar android-actionmode