android - 使用 appcompat-v7 在 Actionmode 中自定义 'back' 箭头颜色

标签 android android-actionbar-compat

我的主主题基于Theme.AppCompat.Light如下:

<style name="core" parent="Theme.AppCompat.Light" >
    <!-- Material, Yo!-->
    <item name="colorPrimary">@color/theme_main_color</item>
    <item name="colorPrimaryDark">@color/deep_purple</item>
    <item name="colorAccent">@color/theme_accent_color</item>
    <item name="android:navigationBarColor" tools:ignore="NewApi">?attr/colorPrimary</item>
    <!-- Toolbar -->
    <item name="theme">@style/my_toolbar_theme</item>
    <item name="drawerArrowStyle">@style/my_drawer_arrow</item>
    <!-- Actionbar -->
    <item name="android:actionBarDivider">@null</item>
    <item name="android:actionBarTabStyle">@null</item>
    <item name="android:actionBarTabBarStyle">@null</item>
    <!-- Contextual Actionbar -->
    <item name="windowActionModeOverlay">true</item>
    <item name="actionModeBackground">?attr/colorAccent</item>
    <item name="actionModeStyle">@style/my_actionmode_style</item>
</style>

<style name="my_drawer_arrow" parent="Widget.AppCompat.DrawerArrowToggle" >
    <item name="spinBars">true</item>
    <item name="color">@color/theme_accent_color</item>
</style>

<style name="my_toolbar_style">
    <item name="android:id">@id/toolbar</item>
    <item name="android:minHeight">?attr/actionBarSize</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:layout_width">match_parent</item>
    <item name="android:background">?attr/colorPrimary</item>
    <item name="android:elevation" tools:ignore="NewApi">5dp</item>
</style>

<style name="my_actionmode_style" parent="Widget.AppCompat.Light.ActionMode.Inverse" >
    <item name="titleTextStyle">@style/my_actionmode_title_style</item>
    <item name="subtitleTextStyle">@style/my_actionmode_subtitle_style</item>
</style>

<style name="my_toolbar_style.gradient">
    <item name="android:background">@drawable/ab_gradient_bg</item>
</style>

<style name="my_toolbar_theme" parent="ThemeOverlay.AppCompat.Dark.ActionBar" >
    <!-- Customize the toolbar here -->
</style>

<style name="my_actionmode_title_style" parent="TextAppearance.AppCompat.Widget.ActionMode.Title">
    <item name="android:textColor">@color/std_white</item>
</style>

<style name="my_actionmode_subtitle_style" parent="TextAppearance.AppCompat.Widget.ActionMode.Subtitle">
    <item name="android:textColor">@android:color/white</item>
</style>

actionmode 中,我希望看到带有白色后退箭头的白色标题/副标题。我已经能够将标题和副标题文本颜色设置为白色,但后退箭头仍然是黑色。此问题仅出现在我使用 SupportActionbar 而不是工具栏的地方(工具栏中的后退箭头为白色)。

这是我在 ActionMode 中的工具栏。

This is my toolbar in ActionMode

这是 ActionMode 中的 actionbar。相同的手机、相同的应用、相同的主题,只是不同的 Activity 。

This is the actionbar in ActionMode

我在主题中找不到任何可以决定这种颜色的东西。根据消息来源,图标是 @drawable/abc_ic_ab_back_mtrl_am_alpha,它是白色的,所以一定是有什么东西在给它着色。这种偏黑的颜色从何而来?

最佳答案

要使用 AppCompat 自定义它:

在您的应用级主题中:

<style name="MyTheme" parent="Theme.AppCompat.Light">
    <item name="actionModeCloseButtonStyle">@style/myclosebutton</item>
</style>

在 CloseButtonStyle 中:

<style name="myclosebutton" parent="Widget.AppCompat.Light.ActionButton.CloseMode">
    <item name="android:tint">#ff0</item> <!-- whatever color -->
</style> 

关于android - 使用 appcompat-v7 在 Actionmode 中自定义 'back' 箭头颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28353285/

相关文章:

android - 如何调整 ListBox 项目高度以适应 Firemonkey (android) 中的文本?

java - 使用适配器应对两种不同情况

android - 在Eclipse中添加库v7 AppCompat时如何解决错误 "No resource found that matches the given name"?

Android - 有没有办法用动画切换 ActionBar 图标?

android - 关于主题、栏等,不确定我是否应该使用 AppCompat

Android ActionBar (ActionBarCompat) Spinner 下拉列表 ?

当我使用 TIdHTTP 进行 HTTPS 调用时,Android 6.0 应用程序崩溃

android - 包裹似乎已损坏

android - 如何分析Android Gradle库的获取时间

android - 无法使用 Android Studio 从 Android 支持库导入 ActionBarCompat