在我的应用“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"

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

其他回答

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)

如果你使用appcompat-v7,你可以子类化AppCompatButtonand setSupportAllCaps(false),然后对你所有的按钮使用这个类。

/**
 * Light extension of {@link AppCompatButton} that overrides ALL CAPS transformation
 */
public class Button extends AppCompatButton {
    public Button(Context context, AttributeSet attrs) {
        super(context, attrs);
        setSupportAllCaps(false);
    }

    public Button(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        setSupportAllCaps(false);
    }
}

请参阅AppCompatButton#setSupportAllCaps(boolean) Android文档。

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

android:textAllCaps="false"

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

你可以添加android:textAllCaps="false"按钮。

按钮文本可能会被应用于所有按钮的应用程序主题转换为大写。检查主题/样式文件设置属性android:textAllCaps。

默认情况下,按钮在android提供所有大写关键字。如果你想按钮文本是小写或混合大小写,你可以禁用textAllCaps标志使用android:textAllCaps="false"