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


当前回答

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

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

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

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

其他回答

使用这行android:textAllCaps="false"在你的xml

<Button
            android:id="@+id/btn_login"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/login_str"
            android:background="@color/colorBlue"
            android:textColor="@color/colorWhite"
            android:textAllCaps="false"
           />

按样式添加这一行

    <item name="android:textAllCaps">false</item>

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

mButton.setTransformationMethod(null);

如果你已经到达这里,因为你的facebook按钮文本出现在所有的大写,然后只需添加这个android:textAllCaps="false"在你的xml文件。这对我很管用。

如果你使用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文档。