1

I have this for my alert dialogs, and this works perfect

 ContextThemeWrapper ctw = new ContextThemeWrapper( MvcnContactList.this, R.style.MyTheme );
                alertDialogBuilder = new AlertDialog.Builder(ctw);
//set some views and onclick listeners
                alertDialog = alertDialogBuilder.create();
                alertDialog.setCancelable(false);
                alertDialog.show();

But I have a about preference dialog, and I want this dialog to have the same stile like my alerts dialog. But I do not know hot to apply this style to my dialog

public class About extends DialogPreference {
    public AboutDialog(Context oContext, AttributeSet attrs)
    {
        super(oContext, attrs); 
    }
}

NOTE: I put android:style="@style/impex_dialog" in my pref.xml file, and this style tag it is not recognised.

Lukap
  • 31,523
  • 64
  • 157
  • 244

1 Answers1

0

Alert dialog uses:

com.android.internal.R.style.Theme_Dialog_Alert

From Android source:

protected AlertDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
    super(context, com.android.internal.R.style.Theme_Dialog_Alert);
    setCancelable(cancelable);
    setOnCancelListener(cancelListener);
    mAlert = new AlertController(context, this, getWindow());
}

So I guess you should try something like this, as it is defined in themes.xml:

<!-- Default theme for alert dialog windows, which is used by the
        {@link android.app.AlertDialog} class.  This is basically a dialog
         but sets the background to empty so it can do two-tone backgrounds. -->
<style name="Theme.Dialog.Alert" parent="@android:style/Theme.Dialog">
    <item name="windowBackground">@android:color/transparent</item>
    <item name="windowTitleStyle">@android:style/DialogWindowTitle</item>
    <item name="windowIsFloating">true</item>
    <item name="windowContentOverlay">@null</item>
</style>
Caner
  • 57,267
  • 35
  • 174
  • 180