3

Shortly, I want to make option menu text in lower case, for example, save, not SAVE.
My app use toolbar in the latest appcompact library. I tried many ways but don't work at all. There are some related questions but don't work for me:
Android ActionBar MenuItem LowerCase
How to change ActionBar Tab textStyle? What I tried:

<style name="MyIDAppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="android:windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="colorPrimary">@color/main</item>
    <item name="colorPrimaryDark">@color/main</item>

    <item name="actionBarTabTextStyle">@style/TextAppearance</item>
    <item name="android:actionBarTabTextStyle">@style/TextAppearance</item>
</style>

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

Really annoyed that Google doesn't provide an option for developers to custom as they want.
Is there any suggestion?

Community
  • 1
  • 1
ductran
  • 10,043
  • 19
  • 82
  • 165

2 Answers2

2

try it custom menu

Activity

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem saveMenu = menu.findItem(R.id.action_save);
    if(saveMenu != null){
        LinearLayout saveLayout = (LinearLayout) LayoutInflater.from(this).inflate(R.layout.custom_save_menu_layout, null);
        saveMenu.setActionView(saveLayout);
        saveMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }
    return super.onPrepareOptionsMenu(menu);
}

custom_save_menu_layout.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Save" />

</LinearLayout>
g0g1
  • 21
  • 3
  • After doing this, the onClickListener should be added manually, otherwise the menu item onClick is disabled – Liuting Dec 22 '15 at 10:52
0

Put it on your app theme:

 <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
       <item name="android:textAllCaps">false</item> 
    </style>
LundinCast
  • 9,412
  • 4
  • 36
  • 48
user3219477
  • 134
  • 3
  • 10