AlertDialog Buttons that do not wrap Lollipop

I am a relatively new Android developer and ran into a problem that I really don't know how to fix, and was hoping you guys could advise!

In Kitkat and below, when I create an AlertDialog that has 2 buttons, the text of both buttons will be wrapped if they go beyond the length of the button. However, in L the text does not fit.

Android 4.4:

Android 4.4

Android L:

Android L

I found several other examples of how people are faced with this problem and are looking for a fix, so I started to make the solutions that were presented to them

Problems with warning dialog buttons in Android L

https://github.com/hotchemi/Android-Rate/issues/40

Based on the answers, the output turned out to be customizable for alertdialog.

values-v21, style.xml. :

<resources>      

    <style name="AppBaseTheme" parent="android:Theme.Material.Light">
        <item name="android:alertDialogTheme">@style/CustomAlertDialogStyle</item>
    </style>

    <style name="CustomAlertDialogStyle" parent="android:Theme.Material.Light.Dialog.Alert">
        <item name="android:buttonBarButtonStyle">@style/CustomButtonBarButtonStyle</item>
        <item name="android:buttonBarStyle">@style/CustomButtonBarStyle</item>
    </style>

    <style name="CustomButtonBarStyle" parent="@android:style/Widget.Material.Light.ButtonBar.AlertDialog">
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:height">@null</item>
        <item name="android:minHeight">@null</item>
    </style>

    <style name="CustomButtonBarButtonStyle" parent="@android:style/Widget.Material.Light.Button.Borderless.Colored">
        <item name="android:layout_width">0dp</item>
        <item name="android:layout_weight">1</item>
    </style>

</resources>

, Lollipop Alertdialog, , , .

, , , , : - , , Android L Android 4.4?

!

+4
2

, , , . , .

, Lollipop, . Stacked full-width buttons. . , , .

, , , AlertDialog . :

  • positive negative . , , .
  • , forceStacking(), . .
+6

. android.app.AlertDiaglog. android.support.v7.app.AlertDialog.

.

+1

All Articles