android - AlertDialog Buttons not wrapping in Lollipop -
i'm relatively new android developer , have run problem don't know how correct , hoping guys might able advise!
in kitkat , below, when create alertdialog has 2 buttons, text of both buttons wrap if extend beyond length of button. however, in l, text refuses fit.
android 4.4:

android l:

i found other examples of people having issue , looking fix, started poking through solutions presented them
alert dialog buttons problems in android l
https://github.com/hotchemi/android-rate/issues/40
based on answers, conclusion appeared custom style alertdialog.
i created values-v21 folder, , in had styles.xml. looks following, 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, saw no visible change @ in lollipop alertdialog, , still not quite familiar enough the layout values see might wrong.
so after poking around while, thought ask: know how go making android l button text word-wrap similar android 4.4?
thanks!
as said, new design guidelines state dialogs should have clear , concise texts, let user take fast decision. having long long actions discouraged.
however, lollipop onward, new design pattern has been allowed accomodate larger texts. take here , scroll down stacked full-width buttons. can have buttons in stack, , use full dialog width. doesn't solve problem, in still limited full width, help.
as how it, think alertdialog class not provide easy methods in direction. few suggestions:
- forget
positive,negativebuttons, , set custom view dialog no buttons @ all. in view can have title, message and buttons wish. - use great library, give dialogs fresh design on older devices , has convenient method called
forcestacking(), can read. it's easy implement.
Comments
Post a Comment