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



Related Posts

Fix Plugin [id: ‘’, version: ‘7.1.3’, apply: false] was not found in any of the following sources

Here is how to fix Plugin [id: ‘’, version: ‘7.1.3’, apply: false] was not found in any of the following sources This error is caused by mismatching…

Get Age from Date of Birth in Java Android

Here is how to get a user’s age from date of birth If you need get a user’s age from a given date of birth string, this…

How to Check if String Array Contains a Specific String in Android

Here is how to get a specific value or String from Array in Android To check if a string array contains a specific string, you can use…

Make Android WebView Support Razorpay Payment

How to Support Razorpay Payment and UPI in Android WebView? Android webview is inexpensive and easy way to make apps for websites. But to support some specific…

Make Android Webview Support PayTM Google Pay PhonePe UPI

GooglePay, Phonpe and PayTM support in Android WebView If you have built an android app for your new ecommerce website or any other website that needs accept…

Leave a Reply

Your email address will not be published.