I have an issue with the Dialog.Builder
, where the Buttons are cut off.
How can I resolve this or is this an issue for Motorola devices?
- making the text shorter is not a solution
- I expect the same behaviour like the S5-screenshot, Buttons too long -> Buttons below each other
Device: Motorola Moto G / OS: Android 5.0.2
Device: Galaxy S5 / OS: Android 5.0.2
Here's the code and theme for showing the Dialog
public void showDialog(final String title, final String message,
final OnClickListener onClickPositive,
final OnClickListener onCLickNegative, final String positiveButton,
final String negativeButton, final boolean cancelable) {
if (!isFinishing()) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (dialog != null && dialog.isShowing()) {
dialog.cancel();
}
Builder builder;
if (android.os.Build.VERSION.SDK_INT >= 14) {
builder = new AlertDialog.Builder(new ContextThemeWrapper(
MyActivity.this,
android.R.style.Theme_DeviceDefault_Light_Dialog));
} else {
builder = new Builder(MyActivity.this);
}
if (title != null) {
builder.setTitle(title);
}
if (message != null) {
builder.setMessage(message);
}
if (positiveButton != null) {
builder.setPositiveButton(positiveButton, onClickPositive);
}
if (negativeButton != null) {
builder.setNegativeButton(negativeButton, onCLickNegative);
}
builder.setCancelable(cancelable);
dialog = builder.show();
colorizeDialog(dialog);
}
});
}
}
//theme-xml
<style name="Theme.DeviceDefault.Light.Dialog" parent="Theme.Holo.Light.Dialog" >
<item name="android:windowTitleStyle">@android:style/DialogWindowTitle.DeviceDefault.Light</item>
<item name="android:windowAnimationStyle">@android:style/Animation.DeviceDefault.Dialog</item>
<item name="android:buttonBarStyle">@android:style/DeviceDefault.Light.ButtonBar.AlertDialog</item>
<item name="borderlessButtonStyle">@android:style/Widget.DeviceDefault.Light.Button.Borderless.Small</item>
<item name="textAppearance">@android:style/TextAppearance.DeviceDefault.Light</item>
<item name="textAppearanceInverse">@android:style/TextAppearance.DeviceDefault.Light.Inverse</item>
</style>
########################
UPDATE EDIT
Seems like, the behaviour is not the same on every device. We have a second issue, with adding the "neutral" Button. Again, Galaxy S5 adding buttons below each other (from top to bottom: positiv, neutral, negative)
Motorola Moto G (API 5.0.2 / left side) shows neutral Button in the middle (red "Abbrechen") and cuts again the button text (blue arrow).
Nexus 4 (API 4.3 / right side) shows the neutral Button at the left side, instead of in the middle
Seems like we have to implement an custom dialog....