Change color of window frame

How do I go about changing the color of the frame of this dialog? I've tried a bunch of things and nothing works.

<?xml version="1.0" encoding="utf-8"?>
  <style name="CustomDialogTheme" parent="@android:style/Theme.Dialog">               
    <item name="android:windowNoTitle">true</item>

Asked by: John732 | Posted: 25-01-2022

Answer 1

You mean white frame ? I think it's a part of 9-patch drawable you can look up how Theme.Dialog is build in the SDK_FOLDER\platforms\android-sdkversion\data\res\values and then styles.xml and themes.xml

As i've said, the white frame is a part of the background image. its panel_background.9.png So if you want to change frame - you'll need different background image + need to overwrite in style setting it.

 <item name="android:windowBackground">@android:drawable/panel_background</item> 

and you'll need to define a style that will be derived from Theme.Dialog and have this

<item name="android:windowBackground">@drawable/your_drawable</item> 

so if you put in styles.xml something like

<style name="NewBorderDialogTheme" parent="android:Theme.Dialog">
 <item name="android:windowBackground">@drawable/your_drawable</item> 

Put new drawable and set your activity to the new theme - you should see your new border

Answered by: Alina887 | Posted: 26-02-2022

Answer 2

If you want to do it Programatically, try below code:

What you have to do:

When AlertDialog is visible on your screen, OnShowListener is called. So, by adding dialog.setOnShowListener(this) you will be able to customize your AlertDialog.


// Create AlertDialog
AlertDialog.Builder adb = new AlertDialog.Builder(context1);
    .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {

AlertDialog dialog = adb.create();

// Make some UI changes for AlertDialog
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
    public void onShow(final DialogInterface dialog) {

        // Add or create your own background drawable for AlertDialog window
        Window view = ((AlertDialog)dialog).getWindow();

        // Customize POSITIVE, NEGATIVE and NEUTRAL buttons.
        Button positiveButton = ((AlertDialog)dialog).getButton(DialogInterface.BUTTON_POSITIVE);

        Button negativeButton = ((AlertDialog)dialog).getButton(DialogInterface.BUTTON_NEGATIVE);

        Button neutralButton = ((AlertDialog)dialog).getButton(DialogInterface.BUTTON_NEUTRAL);

Answered by: Melanie114 | Posted: 26-02-2022

Similar questions

How to change the pitch of a .wav file in Android?

Can somebody tell me how to change the pitch of a wave file in Android?

java - Change Rating Bar on Android

I have a ratingbar in my app, and I would like when I pass the mouse over it, the rating changes How can I do that ? it's possible? best regards

android - Any way to change the color of a radio button?

I'm working on an android form with a radio group containing a set of radio buttons. From what I can tell there is no way to set the color a radio button highlights when you select it. It seems to always default to some bright green color. Is this something that is editable or no? Thanks

Android : How change focus on form with out user action?

I've a form with 2 fields, after First login, i store the Mail in SharedPreferences and i restore when user start app again, But how to set focus on Pass Field ? it's not very nice to see that mail is fill but focus is still on mail field. Thanks &lt;EditText android:id="@+id/Email" android:text="" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+i...

android - digital compass problem

I am creating an augmented reality application and I noticed that the stored locations don't appear appear on the correct direction if I try to use the camera view (using layar or wikitude API). The problem is that the digital compass doesn't show north correctly when you try to look at the known objects through the camera view. If align the phone with the ground (look at my shoes) the locations appear at the screen accord...

android - How to remove labels from a MapView?

I am trying to make a satellite view (via a MapView) without labels. How can I do this?

android - Custom title with image

i'm creating custom title for activity by disabling standard one and managing everything myself. I wonder if it's possible to replace/theme standart title to my needs. I can customize size, background image, and text via themes by changing windowXYZStyle items. The only thing i couldn't find - how i can add image instead of text. I've tried requestWindowFeature(Window.FEATURE_CUSTOM_TITLE) and ...

canvas - Android draw with blur

I need do draw on Android's Canvas using Blur effect, it is a very simple feature, I need to draw a circular area, which is blurred (the foreground) and the background transparent, I can do everything with manipulating the colour alpha to do it with custom transparency but I need it to be blurred instead of transparent.. any ideas?

layout - How to resize a android webview after adding data in it

In a layout (linear, vertical) hierarchy I've got several views and one of them is a WebView. They all have same parameters: android:layout_width="fill_parent" android:layout_height="wrap_content" For all views, the spacing between elements is correctly handled but for the Webview there is a lot of spaces after the displayed text inside. I set the (HTML) text of the webview in the ...

How to find easily the source of an android class

I know I can access android source code from, but it's hard to select the right git repo if I only know the package and the name of an android class. Isn't there a way to locate a file in

camera - Android Intent Save Path

At the moment I am using two intents. One for voice-recording, another for the camera: Intent photoIntent = new Intent(""); startActivityForResult(photoIntent, ACTIVITY_TAKE_PHOTO); Intent voiceIntent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION); startActivityForResult(voiceIntent, ACTIVITY_RECORD_SOUND); My aim is to put an Extra to each of t...

Android "hover" event in custom layout

I have a custom layout that I have written that basically just displays a bunch of ImageViews. I am handing onTouch events for all the ImageViews in my layout. However, if a user touches one imageView and then drags over another ImageView, I would like to be able to handle that as well. How would I go about capturing this behaviour?

android - What is the ideal place to cache images?

I am fetching a lot of thumbnails in my application from a remote server and lazy-loading these in a list view. The image fetches run in a background AsynTask and when completed the fetched images are stored in a HashMap using SoftReferences. This works just fine but when the images in the cache gets GC’d, the fetches have to be rerun. I could have stored them on the SD card so there would be no...

How to create a tree view in Android?

There are no controls in Android that provide Tree-like View. There is an ExpandableList View which I suspect could be used to creating one. Have you tried imlpementing such a control? How would one implement such a control in Android?

Still can't find your answer? Check out these communities...

Android Google Support | Android Community | Android Community (Facebook) | Android