Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
485 views
in Technique[技术] by (71.8m points)

android - Lollipop capitalizes Buttons' text in my app

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...