Search code examples
androidandroid-actionbarmaterial-designthemes

MaterialComponents actionbar text cannot be made lowercase? (textAllCaps does not work)


I am using this theme Theme.MaterialComponents.

My problem is that I added some menu, which is simple clickable text, and that is displayed on the action bar as UPPERCASE (see the image below):

a problem

My resourse file contains this text as follows:

<string name="register_user_action_v2">Создать</string>

I tried adding actionMenuTextAppearance styles to my theme:

<style name="Theme.MyDarkMaterialDesignBar" parent="Theme.MaterialComponents">

...

<item name="android:actionMenuTextAppearance">@style/MyMenuTextAppearance</item>
<item name="actionMenuTextAppearance">@style/MyMenuTextAppearance</item>

...

</style>

where MyMenuTextAppearance:

<style name="MyMenuTextAppearance" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Menu">
        <item name="android:textAllCaps">false</item>
        <item name="textAllCaps">false</item>
</style>

But still, it does not work.

How to make this text looks like normal (e.g. Создать, not СОЗДАТЬ )

P.S. Maybe it is a problem with my @style/TextAppearance.AppCompat.Widget.ActionBar.Menu and I should use something different for MaterialComponent theme?

Thanks!


Solution

  • You can use:

     <com.google.android.material.appbar.MaterialToolbar
                android:id="@+id/toolbar"
                ../>
    
    toolbar = findViewById(R.id.toolbar); //Material toolbar
    setSupportActionBar(toolbar);
    

    with this style:

      <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>
    

    enter image description here