在我的应用“Tide Now WA”中,我最近测试了它的兼容性 新款Nexus 9平板电脑(Lollipop - API 21)。

它写一些按钮文本。这个应用程序使用Android 2.3和Android正确地编写文本 4.0. 即混合大写字母和小写字母。

当同一个应用程序在我的Nexus 9上运行时,所有的字母 正文均大写。

FWIW我的清单包含以下语句:

users -sdk android:minSdkVersion="10" android:targetSdkVersion="14"

我可以在我的代码中修复这个问题,还是操作系统中的一个bug 谢谢


当前回答

这个正在工作....只要在你的代码中在你的底部代码中添加这个:

android:textAllCaps="false"

它应该停用的大写字母,你试图键入小。

其他回答

这在应用程序代码中是可以通过设置按钮的TransformationMethod来修复的。

mButton.setTransformationMethod(null);

我不知道为什么会发生这种情况,但有3个微不足道的尝试:

在layout-v21中使用android:textAllCaps="false" 以编程方式更改按钮的转换方法。mButton.setTransformationMethod(空); 检查全大写的样式

注意:公共无效setAllCaps(boolean allCaps), android:textAllCaps从API版本14可用。

OK, just ran into this. Buttons in Lollipop come out all uppercase AND the font resets to 'normal'. But in my case (Android 5.02) it was working in one layout correctly, but not another!? Changing APIs didn't work. Setting to all caps requires min API 14 and the font still resets to 'normal'. It's because the Android Material Styles forces a change to the styles if there isn't one defined (that's why it worked in one of my layout and not the other because I defined a style). So the easy fix is to define a style in the manifest for each activity which in my case was just: android:theme="@android:style/Theme.NoTitleBar.Fullscreen" (hope this helps someone, would have saved me a couple of hours last night)

在Android Studio IDE中,你必须点击Filter图标来显示专家属性。然后您将看到textAllCaps属性。勾选,然后取消勾选。

我不知道为什么@user1010160的答案是0。如果我有足够的声誉,我会给它+1。

由于我的应用程序是为小于14的API设计的,我不想在我的程序中添加代码,直到我读到他的答案,我才找到解决方案。他说的是,即使你已经做了什么是需要在应用程序样式它不会工作,除非你添加一个样式到你的活动,在那里你设置textAllCaps为假。

活动有一个样式是不够的(我的活动有一个样式),因为样式可能默认为AllCaps属性。你必须在activity中显式地设置,那个属性为false。

我现在在清单文件的应用程序和活动部分中都有它。