3

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.

fragon
  • 3,391
  • 10
  • 39
  • 76
  • Possible duplicate of [Why is my Button text forced to ALL CAPS on Lollipop?](http://stackoverflow.com/questions/26958909/why-is-my-button-text-forced-to-all-caps-on-lollipop) – SagiLow Aug 30 '16 at 08:40

2 Answers2

20

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

Alex Lockwood
  • 83,063
  • 39
  • 206
  • 250
  • 4
    this is about the stupidest design they could have come up with and just made everybody run around and do work – bharal Nov 02 '16 at 17:14
4

Actually this is possible:

new AlertDialog.Builder(context, R.style.StackedAlertDialogStyle)

StackedAlertDialogStyle:

  <style name="StackedAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
        <item name="buttonBarButtonStyle">@style/StackedButtonBarButtonStyle</item>
    </style>

    <style name="StackedButtonBarButtonStyle" parent="Widget.AppCompat.Button.ButtonBar.AlertDialog">
        <item name="android:layout_gravity">right</item>
        <item name="android:textAllCaps">false</item>
    </style>

Now you can see the buttons not in capital.

TharakaNirmana
  • 10,237
  • 8
  • 50
  • 69