1
I have a problem in a prompt, on Android Kitkat (19) or previous version looks like this:
But in Lollipop or newer versions it is misaligned:
Follow the code of the Lieutenant who makes this code:
final AlertDialog dialog = builder.create();
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
public void onShow(final DialogInterface dialogInterface) {
Button noButton = ((AlertDialog) dialog).getButton(DialogInterface.BUTTON_NEGATIVE);
Button yesButton = ((AlertDialog) dialog).getButton(DialogInterface.BUTTON_POSITIVE);
noButton.setTextColor(Color.parseColor("#333333"));
yesButton.setTextColor(Color.parseColor("#333333"));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Drawable buttonDrawableNo = getResources().getDrawable(R.drawable.button_prompt, context.getTheme());
Drawable buttonDrawableYes = getResources().getDrawable(R.drawable.button_prompt, context.getTheme());
noButton.setBackground(buttonDrawableNo);
yesButton.setBackground(buttonDrawableYes);
}
else
{
Drawable buttonDrawableNo = getResources().getDrawable(R.drawable.button_prompt);
Drawable buttonDrawableYes = getResources().getDrawable(R.drawable.button_prompt);
if (Build.VERSION.SDK_INT > 15) {
noButton.setBackground(buttonDrawableNo);
yesButton.setBackground(buttonDrawableYes);
} else {
noButton.setBackgroundDrawable(buttonDrawableNo);
yesButton.setBackgroundDrawable(buttonDrawableYes);
}
}
noButton.invalidate();
yesButton.invalidate();
}
});