Android的动作条菜单项小写 [英] Android ActionBar MenuItem LowerCase

查看:254
本文介绍了Android的动作条菜单项小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使菜单项冠军中的动作条为小写。

I want to make MenuItem title in the ActionBar to LowerCase.

我menu.xml文件

my menu.xml

  <item android:id="@+id/register"
    android:title="Register"
    android:showAsAction="ifRoom|withText"/>

  <item android:id="@+id/unregister"
    android:title="Unregister"
    android:showAsAction="ifRoom|withText"/>

在动作条它看到注册和取消注册,但我想它认为的注册和注销。

On the ActionBar it sees "REGISTER" and "UNREGISTER", but I want that it sees as "Register" and "Unregister".

时有可能使在菜单项第一个字母上,下一个字母下? 我怎么能做到这一点?

Is it possible to make first letter upper and next letters lower at MenuItem? And how I can do that?

推荐答案

解决方案为原始动作条实施:

Solution for native ActionBar implementation:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="MyTheme" parent="android:Theme.Holo">
        <item name="android:actionMenuTextAppearance">@style/MyMenuTextAppearance</item>
    </style>
    <style name="MyMenuTextAppearance" parent="android:TextAppearance.Holo.Widget.ActionBar.Menu">
        <item name="android:textAllCaps">false</item>
    </style>
</resources>

如果您使用的是ActionBarSherlock有两种不同的方法:

If you are using ActionBarSherlock there are two different approaches:

1)创建布尔资源 abs__config_actionMenuItemAllCaps 键,将其设置为

1) Create boolean resource abs__config_actionMenuItemAllCaps and set it to false:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <bool name="abs__config_actionMenuItemAllCaps">false</bool>
</resources>

2),或创建主题与被覆盖的 actionMenuTextAppearance ,并用它在的Andr​​oidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="MyTheme" parent="Theme.Sherlock">
        <item name="actionMenuTextAppearance">@style/MyMenuTextAppearance</item>
        <item name="android:actionMenuTextAppearance">@style/MyMenuTextAppearance</item>
    </style>
    <style name="MyMenuTextAppearance" parent="TextAppearance.Sherlock.Widget.ActionBar.Menu">
        <item name="android:textAllCaps">false</item>
    </style>
</resources>

请注意:有强制菜单项是在pre-ICS(<一个大写错误的ActionBarSherlock href="https://github.com/JakeWharton/ActionBarSherlock/issues/969">https://github.com/JakeWharton/ActionBarSherlock/issues/969).我此刻提交补丁,但不合并现在你可以用我的叉:<一href="https://github.com/alexander-mironov/ActionBarSherlock/tree/dev">https://github.com/alexander-mironov/ActionBarSherlock/tree/dev,我会更新这个答案时,我的code在主存储库合并。

PLEASE NOTE: there is bug in ActionBarSherlock that forces MenuItem to be upper case on pre-ICS (https://github.com/JakeWharton/ActionBarSherlock/issues/969). I've submitted patch but it is not merged at the moment. For now you can use my fork: https://github.com/alexander-mironov/ActionBarSherlock/tree/dev, I will update this answer when my code is merged in the main repository.

更新:我的补丁已经被合并到主ActionBarSherlock库

UPDATE: my fix has been merged into main ActionBarSherlock repository.

这篇关于Android的动作条菜单项小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆