我有一个主题,希望所有关于活动的文本视图都被大写。因此,我将 textAllCaps 设置为样式,然后将其应用于我的主题中的 textViewStyle ,如下所示
<style name="Widget.Apex.TextView" parent="android:Widget.TextView">
<item name="android:textAppearance">?android:attr/textAppearanceSmall</item>
<item name="android:textAllCaps">true</item>
</style>
<style name="MyTheme" parent="@android:style/Theme.Holo">
<item name="android:textViewStyle">@style/Widget.Apex.TextView</item>
</style>
不幸的是,这具有将我的应用程序标题、ActionBar 字幕和弹出菜单项变为大写的副作用。所以我想我只需将我的主题中的 ActionBarStyle、textAppearanceLargePopupMenu 和 textAppearanceSmallPopupMenu 属性设置为具有 textAllCaps=false 的自定义样式。但是,这不起作用。我知道我的主题正在被应用,因为如果我设置 textColor 或 textStyle 它们都会应用于标题和菜单项。是否可以覆盖这些样式中的 textAllCaps?
<style name="Widget.Apex.TextView" parent="android:Widget.TextView">
<item name="android:textAppearance">?android:attr/textAppearanceSmall</item>
<item name="android:textAllCaps">true</item>
</style>
<style name="TextAppearance.Apex.Widget.ActionBar.Title" parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textAllCaps">false</item>
<item name="android:textStyle">italic</item>
</style>
<style name="TextAppearance.Apex.Widget.ActionBar.Subtitle" parent="android:TextAppearance.Holo.Widget.ActionBar.Subtitle">
<item name="android:textAllCaps">false</item>
<item name="android:textStyle">italic</item>
<item name="android:textColor">#FF0000</item>
</style>
<style name="TextAppearance.Apex.Widget.PopupMenu.Large" parent="android:TextAppearance.Holo.Widget.PopupMenu.Large">
<item name="android:textAllCaps">false</item>
<item name="android:textStyle">italic</item>
<item name="android:textColor">#FF0000</item>
</style>
<style name="TextAppearance.Apex.Widget.PopupMenu.Small" parent="android:TextAppearance.Holo.Widget.PopupMenu.Small">
<item name="android:textAllCaps">false</item>
<item name="android:textStyle">italic</item>
<item name="android:textColor">#FF0000</item>
</style>
<style name="Widget.Apex.ActionBar" parent="android:Widget.Holo.ActionBar">
<item name="android:titleTextStyle">@style/TextAppearance.Apex.Widget.ActionBar.Title</item>
<item name="android:subtitleTextStyle">@style/TextAppearance.Apex.Widget.ActionBar.Subtitle</item>
</style>
<style name="MyTheme" parent="@android:style/Theme.Holo">
<item name="android:actionBarStyle">@style/Widget.Apex.ActionBar</item>
<item name="android:textAppearanceLargePopupMenu">@style/TextAppearance.Apex.Widget.PopupMenu.Large</item>
<item name="android:textAppearanceSmallPopupMenu">@style/TextAppearance.Apex.Widget.PopupMenu.Small</item>
<item name="android:textViewStyle">@style/Widget.Apex.TextView</item>
</style>
谢谢,乔纳森