我正在使用此主题Theme.MaterialComponents
。
我的问题是我添加了一些菜单,该菜单是简单的可单击文本,并且在操作栏上显示为大写(请参见下图):
我的资源文件包含以下文本:
<string name="register_user_action_v2">Создать</string>
我尝试在主题中添加actionMenuTextAppearance样式:
<style name="Theme.MyDarkMaterialDesignBar" parent="Theme.MaterialComponents">
...
<item name="android:actionMenuTextAppearance">@style/MyMenuTextAppearance</item>
<item name="actionMenuTextAppearance">@style/MyMenuTextAppearance</item>
...
</style>
其中MyMenuTextAppearance
:
<style name="MyMenuTextAppearance" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Menu">
<item name="android:textAllCaps">false</item>
<item name="textAllCaps">false</item>
</style>
但是仍然无法正常工作。
如何使此文本看起来像普通文本(例如Создать,而不是СОЗДАТЬ)]
P.S。也许我的@style/TextAppearance.AppCompat.Widget.ActionBar.Menu
有问题,我应该为MaterialComponent
主题使用其他内容吗?
谢谢!
您可以使用:
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
../>
toolbar = findViewById(R.id.toolbar); //Material toolbar
setSupportActionBar(toolbar);
具有这种样式:
<style name="AppTheme" parent="Theme.MaterialComponents.*">
<item name="actionMenuTextAppearance">@style/actionbar_menu</item>
</style>
<style name="actionbar_menu" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Menu">
<item name="textAllCaps">false</item>
</style>