1

i have written a program for a dialog box which pops up when clicked on the image button , but unfortunately its header background is black and i m not able to change its color , the portion above my text Dialog Box, i will post a snapshot of my dialog box , please need some help enter image description here

@Override
        public void onClick(View v) {

            PopupMenu popup = new PopupMenu(wrapper, v);

            popup.getMenuInflater().inflate(R.menu.home, popup.getMenu());

            popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {

                @Override
                public boolean onMenuItemClick(MenuItem item) {

                    android.app.FragmentManager manager = getFragmentManager();
                    final MenuDialog dialog = new MenuDialog();

                    dialog.show(manager, "About App");

                    return true;
                }
            });
            popup.show();
        }
    });

1 Answer 1

1

You can use the code

final Dialog mailDialog = new Dialog(MainActivity.this);
mailDialog.getWindow().setBackgroundDrawableResource(R.drawable.dialog_box);

dialog_box.xml

<?xml version="1.0" encoding="utf-8"?>

<corners
    android:bottomLeftRadius="5dp"
    android:bottomRightRadius="5dp"
    android:topLeftRadius="5dp"
    android:topRightRadius="5dp" />

<gradient
    android:angle="-90"
    android:centerColor="#660D1E4A"
    android:endColor="#66011444"
    android:startColor="#66505E7F"
    android:type="linear"
     />

<stroke
    android:dashGap="0dp"
    android:dashWidth="0dp"
    android:width="1dp"
    android:color="#ffffffff" />

This is a custom dialog box you can add as much attribute you want.Hope this Would help

Sign up to request clarification or add additional context in comments.

5 Comments

sir , dialog.getwindow() is not available in the list , now what to do ??
I have tested this code in eclipse and it worked for me.getwindow() is function available for dialog
any other solution sir ?? or anyone can post a different solution , it would be of a great help
You can refer to this link .Its very easy to change the background color of a header of dialog box and if this answers your question you can accept my answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.