I'm a relatively new Android developer and have run into a problem that I don't really know how to correct and was hoping you guys might be able to advise!
In Kitkat and below, when I create an AlertDialog that has 2 buttons, the text of both buttons would wrap if they extend beyond the length of the button. However, in L, the text refuses to fit.
Android 4.4:
Android L:
I found some other examples of people having this issue and looking for a fix, so I started poking through the solutions that were presented for them
Alert dialog buttons problems in Android L
https://github.com/hotchemi/Android-Rate/issues/40
Based on the answers, the conclusion appeared to be a custom style for the alertdialog.
I created a values-v21 folder, and in it had a styles.xml. It looks like the following, from the above:
<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>
Unfortunately, I saw no visible change at all in the lollipop Alertdialog, and I am still not quite familiar enough with the the layout values to see what might be wrong.
So after poking around for a while, I thought I would ask: Does anyone know how to go about making the Android L button text word-wrap similar to the Android 4.4?
Thanks!