0

I have a class that opens a very simple AlertDialog with:

        new AlertDialog.Builder(this)
                .setIcon(android.R.drawable.ic_dialog_alert)
                .setTitle(TITLE)
                .setMessage(MESSAGE)
                .setPositiveButton("YES", (dialog, which) -> {
                    f.delete();
                })
                .setNegativeButton("CANCEL", null)
                .show();

This class is called twice in my app, in different activities.

The problem is that the button layout is different depending on the activity: in one, the buttons are big filling the parent (this is what I want). In the other, they are small and left justified.

Why is this? Shouldn't be the same, being the same method on the same class? Is the containing activity influencing the behavior? How should I fix this without fancy calling layoutparameters on the AlertDialog?

2
  • 1
    Is the containing activity influencing the behavior? it can, it depends on your styles and themes Commented Apr 10, 2021 at 18:42
  • I see, probably that's it. I better force the style through a custom R.style.MyAlertDialog. Thanks! Commented Apr 10, 2021 at 19:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.