Yes, it seems that the order of the buttons is related to the theme, not the version. Unlike the layout "alert_dialog.xml", alert_dialog_holo.xml "puts" button1 "(positive) to the right and" button2 "(negative) to the left.
The layout is determined by com.android.internal.app.AlertController:
public AlertController(Context context, DialogInterface di, Window window) { TypedArray a = context.obtainStyledAttributes(null, com.android.internal.R.styleable.AlertDialog, com.android.internal.R.attr.alertDialogStyle, 0); mAlertDialogLayout = a.getResourceId(com.android.internal.R.styleable.AlertDialog_layout, com.android.internal.R.layout.alert_dialog);
The Theme attribute "alertDialogStyle" refers to the "AlertDialog" style, which is a set of attributes that describe the AlertDialog theme, the "layout" attribute can point to a layout resource, otherwise layout / alert_dialog is used.
In the Android source, you can see that "Theme.Holo" uses "AlertDialog.Holo", which in turn refers to "layout / alert_dialog_holo", and in "Theme" uses "AlertDialog", which does not contain a layout and by The default value is the code value.
themes.xml:
<style name="Theme"> <item name="alertDialogStyle">@android:style/AlertDialog</item> <style name="Theme.Holo"> <item name="alertDialogStyle">@android:style/AlertDialog.Holo</item>
styles.xml:
<style name="AlertDialog"> … </style> <style name="AlertDialog.Holo" parent="AlertDialog"> … <item name="layout">@android:layout/alert_dialog_holo</item> … </style>
The actual theme used is apparently determined by the device’s settings.
themes_device_defaults.xml:
<style name="Theme.DeviceDefault" parent="Theme.Holo" > <item name="alertDialogStyle">@android:style/AlertDialog.DeviceDefault</item>
styles_device_defaults.xml:
<style name="AlertDialog.DeviceDefault" parent="AlertDialog.Holo"> </style>
I think Samsung is simply installing something else here to maintain their appearance, as Filio described.