Android: Difference between positive, negative, and neutral button

27,666

Solution 1

Just the position they take within the dialog...

  • On devices prior to Honeycomb, the button order (left to right) was POSITIVE - NEUTRAL - NEGATIVE.
  • On newer devices using the Holo theme, the button order (left to right) is now NEGATIVE - NEUTRAL - POSITIVE.

Solution 2

On Lolipop and above or whenever you use Theme.AppCompat.Light style, the buttons are arranged from left to right: Neutral, Negative and Positive.

Note: the Neutral button is always placed at the extreme left while the Negative and Positive buttons are packed together towards the right. [Took me awhile battling with this.]

Material Design Dialog Button Placements

Solution 3

To quote the documentation:

Note: You can only add one of each button type to the AlertDialog. That is, you cannot have more than one "positive" button. This limits the number of possible buttons to three: positive, neutral, and negative. These names are technically irrelevant to the actual functionality of your buttons, but should help you keep track of which one does what.

So it's entirely down to how you want to use it. It also influences order in a left-to-right sense (see Devunwired's answer for the ordering).

Solution 4

According to Material Design Style Guide you shouldn't use neutral buttons anymore:

Dialog specs

Solution 5

As stated earlier, it defines the order, and you can have only one button of each kind. However the order I get (left to right) is Neutral, Negative, Positive both on a phone running Marshmallow and Android Studio emulator configured to Jelly Bean. I use AppCompat libs, so the behavior I observe may be typical for newer Android versions. Anyway it is not Negative, Neutral, Positive (i.e. not as it was stated earlier).

Share:
27,666
bibismcbryde
Author by

bibismcbryde

Updated on May 08, 2020

Comments

  • bibismcbryde
    bibismcbryde about 4 years

    Is there a functional difference between positive, negative, and neutral buttons, particularly in the context of AlertDialogs?