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

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

问题描述

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

示例按钮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"
        />

该问题的解决方案是什么?我希望我的应用在所有软件版本上看起来都一样.

解决方案

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

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

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:

Example Button 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"
     />

Example button 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"
        />

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

解决方案

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.

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

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

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