Lollipop capitalizes Buttons#39; text in my app(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, Button
s 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 在我的应用程序中将按钮的文本大写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Lollipop 在我的应用程序中将按钮的文本大写


- Android viewpager检测滑动超出范围 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01