Make a Custom Theme for Android AlertDialogue Java

Creating a custom theme for alertdialogue will change its appearance, in a way you want or to match your application theme and look. here i will explain how to do that with a few lines of code in java. what we have to do is create a new theme specially for alertdialogue and then refer to it from the code

First, go to res > values > styles.xml file. see the image below.

android studio strings image













In styles.xml, create a new theme

Theme code

<style name="MyAlertDialogTheme" parent="Theme.AppCompat.Dialog.Alert">
        <item name="colorAccent">@color/coloraccent</item>
        <item name="android:colorBackground">@color/colorPrimaryDark</item>
        <item name="android:windowBackground">@color/colorPrimaryDark</item>




Android alertdialogue theme image


And in your Activity

AlertDialog.Builder builder = new AlertDialog.Builder(this,; //here we refer to the theme we created in styles

For a detailed explanation of how to create an alertdialogue, go here



, ,

Post navigation


This site uses Akismet to reduce spam. Learn how your comment data is processed.