After a very frustrating evening and some really bad hacks, I fixed the theme for various dialogs (quick-info on longclicking a thumb and exif-info if you must know :)  ). For some reason we couldn’t find this very easily on the web, so why not share this information ;). Object? To make the dialog-background one color (so not only the background of the Views in your layout, but also that of the Title).


1) Make a style. This is simply an XML file in the “values” dir, looking like this:

<?xml version="1.0" encoding="utf-8"?>
	<style name="myBackgroundStyle" parent="@android:style/Theme.Dialog">
		<item name="android:background">#FF0000</item>

You can add this to your activity in the AndroidManifest.xml as “teh internetz” let us believe is the only way (maybe it was a googlefail on our side), but we’re going to do it the smart way:

2) Instead of the normal constructor, we’ll actually add the theme to the constructor.

Dialog myDialog = new Dialog(this,;

And done. That was easy, wasn’t it?

16 comments on How to “theme” an Android Dialog

  1. Ilse says:

    When I read it now, it seems so easy… :-)

  2. ennaN says:

    Ow, and all the stuff about adding the theme to your manifest came from this source:

    It would’ve been cool if the above was mentioned there ;)

  3. Thanks for posting this it was exactly what I was looking for.

  4. Handaru says:

    It’s working. Great tips. Thanks a lot.

  5. Bijendra says:

    Thanks for this valuable information.

  6. Max says:

    How would this be achieved using the

    AlertDialog.Builder builder = new AlertDialog.Builder(this)

    technique instead?

  7. ennaN says:

    I haven’t tried it, but reading the AlertDialog.Builder manual I suppose it works the same? There is constructor (see that link) that not only takes a context, but also an int (theme id).

  8. sai says:

    i want to set sliding drawer in dialog how i can achieve this? help me , thanks in advance

  9. tc says:

    public MyAlertDialog(Context context, String text) {
    setButton(“Ok”, new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int id) {



    Did you mean this?

  10. Andraž says:

    Huh, I’m so glad I found this post, you saved me 1 hour at least…

  11. viswanath says:

    Awesome !!! Thanks a lot.

  12. Arun says:


  13. Sulaiman Khan says:

    Thanks its really helpful……

  14. Dganit says:

    Thanks, it really helped me. it colord everything exept my buttons, do you know how to set those too.

  15. Derrick says:

    Thanks Man it helped me