更新时间:2023-12-04 19:38:52
开始在你的基本主题压倒一切的属性 actionModeStyle
:
Start with overriding attribute actionModeStyle
in your base theme:
<item name="actionModeStyle">@style/LStyled.ActionMode</item>
定义 LStyled.ActionMode
为:
<style name="LStyled.ActionMode" parent="@style/Widget.AppCompat.ActionMode">
<item name="titleTextStyle">@style/LStyled.ActionMode.Title</item>
<item name="subtitleTextStyle">@style/LStyled.ActionMode.Subtitle</item>
</style>
最后:
<style name="LStyled.ActionMode.Title" parent="@style/TextAppearance.AppCompat.Widget.ActionMode.Title">
<item name="android:textColor">@color/color_action_mode_text</item>
</style>
<style name="LStyled.ActionMode.Subtitle" parent="@style/TextAppearance.AppCompat.Widget.ActionMode.Subtitle">
<item name="android:textColor">@color/color_action_mode_text</item>
</style>
这将覆盖指定主题文字颜色(S)为标题和放大器;字幕(如果需要的话)。
This will override theme specified text color(s) for title & subtitle(if needed).
剩下的就是溢出按钮。火了一个支持彩色替换任何图像编辑软件。使用溢出菜单从AppCompat的 RES /绘制-XXXX
文件夹PNG。涂料是白色的。接下来,覆盖 actionOverflowButtonStyle
在你的基本主题,并指定你刚刚修改为PNG:
What's left is the overflow button. Fire up any image editing software that supports color-replacement. Use the overflow menu png from AppCompat's res/drawable-XXXX
folder. Paint it white. Next, override actionOverflowButtonStyle
in your base theme and specify the png you've just modified:
<item name="actionOverflowButtonStyle">@style/LStyled.OverFlow</item>
<style name="LStyled.OverFlow" parent="@style/Widget.AppCompat.ActionButton.Overflow">
<item name="android:src">@drawable/modified_overflow_icon</item>
</style>
没有太多的解释/教程,我可以提供关于主题定制。只有这样,才能获得挂起它是从框架通过[风格] [主题] .xml文件。阅读源$ C $ C也有助于 - 你会得到知道什么属性正在被使用,其中,/如果他们可以定制。
There's not much of an explanation/tutorial that I can provide regarding customization of themes. The only way to get a hang of it is to go through [styles][themes].xml files from the framework. Reading the source code also helps - you'll get to know what attributes are being used and where/if they can be customized.
提点:
我希望能够扩展样式以获得相同的行为,这是 内置在黑暗的主题。
I want to be able to extend a style to get the same behavior that's built into the dark theme.
是的,但是这可能不是期望的。以上的部分将讨论修改溢出菜单图标可以被覆盖 colorControlNormal
属性所取代。 TintManager
(链接)使用从 colorControlNormal
中的颜色值>来着色溢出菜单绘制(其它可绘制之间)。看看数组的内容 TINT_COLOR_CONTROL_NORMAL
源$ C $ C。但是覆盖 colorControlNormal
来修复一个绘制可能改变整体外观和放大器;觉得该应用程序的更糟糕。
Yes, but this might not be desired. The part above that deals with modifying overflow menu icon can be substituted with an overridden colorControlNormal
attribute. TintManager
(Link) uses the color value from colorControlNormal
to tint the overflow menu drawable (among other drawables). Take a look at the contents of array TINT_COLOR_CONTROL_NORMAL
in the source code. But overriding colorControlNormal
to fix one drawable may change the overall look & feel of the app for worse.