【问题标题】:Actionbar menuitem text is uppercase操作栏菜单项文本为大写
【发布时间】:2015-08-03 13:59:29
【问题描述】:

我的操作栏中有一个菜单项,它只显示项目的文本,而不是图标。一切都很好,但不知何故,项目的标题变成了大写。有人可以告诉我我怎样才能让它恢复到定义的状态。 这是我的菜单 xml:

 <?xml version="1.0" encoding="utf-8"?>
    <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" >

        <item
            android:id="@+id/action_download"
            android:orderInCategory="99"
            app:showAsAction="always|withText"
            android:title="Download"/>

    </menu>

我得到一个显示为 DOWNLOAD 而不是 Download 的项目

【问题讨论】:

    标签: android android-actionbar android-appcompat android-actionbar-compat


    【解决方案1】:

    这篇文章可能会有所帮助How to style the menu items on an Android action bar

    基本上,您需要为菜单项应用样式。在样式中,添加

    android:capitalize="none"
    

    希望对你有帮助。

    【讨论】:

      【解决方案2】:

      您已覆盖主题并为操作栏菜单项设置自己的样式

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

      【讨论】:

        【解决方案3】:

        这个对我有帮助(我正在使用 AppCompat)

        <item name="actionButtonStyle">@style/AppTheme.Widget.ActionButton</item>
        
        <style name="AppTheme.Widget.ActionButton" parent="@style/Widget.AppCompat.ActionButton">
            <item name="textAllCaps">false</item>
        </style>
        

        【讨论】:

        • 我有同样的问题,我使用了你的代码,但它不起作用。
        • 尝试将 @style/AppTheme.Widget.ActionButton 放入您的基本主题中
        【解决方案4】:
        <!-- Base application theme. -->
        <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
            <item name="android:textAllCaps">false</item>
        </style>
        

        【讨论】:

        • 这将影响您主题中的所有文本,即所有Buttons 和所有TextViews,所以这绝对不是一个好方法。 stackoverflow.com/a/32757893/882251 是最好的方法。
        猜你喜欢
        • 2013-08-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-10-31
        • 2015-12-17
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多