Lollipop 在我的应用程序中将按钮的文本大写 [英] Lollipop capitalizes Buttons' text in my app

查看:22
本文介绍了Lollipop 在我的应用程序中将按钮的文本大写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序遇到了一个奇怪的问题.当我在真实设备(Android 4.4.4)上测试它时,我所有的按钮文本字段看起来都是我想要的(小写字母).但是当我在模拟器(Android 5.0.1)上启动我的应用程序时,所有按钮文本字段都是大写的.这种行为的原因是什么?我的应用中的一些示例按钮:

I am expreiencing a strange problem with my application. When I am testing it on a real device (with Android 4.4.4) all my Buttons' text fields look how I wanted (lower case letters). But when I launch my application on an emulator (Android 5.0.1) all Button texts fields are capitalized. What is the reason of such behaviour? Some example Buttons from my app:

示例按钮 1:

    <Button
        android:id="@+id/button5"
        android:layout_width="match_parent"
        style="?android:attr/borderlessButtonStyle"
        android:layout_height="wrap_content"
        android:text="@string/finish"
        android:textColor="#FFFFFF"
        android:textSize="30sp"
     />

示例按钮 2:

    <Button
        android:id="@+id/button3"
        android:layout_width="0dp"
        style="?android:attr/borderlessButtonStyle"
        android:layout_height="wrap_content"
        android:text="@string/flower"
        android:textColor="#FFFFFF"
        android:textSize="30sp"
        android:drawableLeft="@drawable/flower"
        android:layout_weight=".75"
        />

这个问题的解决方法是什么.我希望我的应用在所有 sw 版本上看起来都一样.

What is the solution to this problem. I want my app to look the same on all sw versions.

推荐答案

从 Android 5.0 开始,Button 的文本会自动大写.这符合新材料设计指南,您可以找到 这里.

Starting with Android 5.0, Buttons automatically have their text capitalized. This is in accordance with the new material design guidelines, which you can find here.

如果你想强制你的按钮像以前的平台版本一样显示文本,你可以在你的 XML 中设置 android:textAllCaps="false".但是,我建议不要这样做.用户希望他们的应用在 Android Lollipop 中看起来很重要,这意味着他们希望您的按钮以全部大写字母显示文本(即使您的应用在以前的平台版本中显示的文本不同).

If you want to force your buttons to display the text as it does in previous platform versions, you can set android:textAllCaps="false" in your XML. However, I would recommend against this. Users expect their apps to look material in Android Lollipop, and that means they expect your buttons to display text in all capital letters (even if your app displays the text differently in previous platform versions).

这篇关于Lollipop 在我的应用程序中将按钮的文本大写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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