0

I wanna change only default alert dialog backgound but i didn'tfind anything usefull. I don't wanna change custom alert dialog them. I did it . The only thing i want to change default alert dialog background color. How can i change alert dialog backgroudn that is not created by me ?

emowise
  • 121
  • 1
  • 14
  • 1
    Possible duplicate of [Change the background color of a pop-up dialog](https://stackoverflow.com/questions/18346920/change-the-background-color-of-a-pop-up-dialog) – Kunu Oct 08 '18 at 11:08
  • can use black theme AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this, android.R.style.Theme_DeviceDefault_Light_Dialog_Alert); – hemen Oct 08 '18 at 11:10
  • I dont want to do this. I did this custom alert dialog style. I just wanna default alert dialog background color. – emowise Oct 08 '18 at 11:16
  • Possible duplicate of [How can I customize permission dialog in Android?](https://stackoverflow.com/questions/33266328/how-can-i-customize-permission-dialog-in-android) – Adarsh Yashvanth Oct 08 '18 at 11:49

2 Answers2

1

In short on run time permissions dialog, you can't customize it.

When your app calls requestPermissions(), the system shows a standard dialog box to the user. Your app cannot configure or alter that dialog box. If you need to provide any information or explanation to the user, you should do that before you call requestPermissions(), as described in Explain why the app needs permissions.’

If you want to change the background of alertdialog, use belwo code: Add this line and you will able to change the background color of alert dialog.

        AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                        builder.setTitle("Say Hello!");
                        builder.setMessage("Are you want to do this?");
                        AlertDialog dialog = builder.create();
                        dialog.show();

              dialog.getWindow().setBackgroundDrawable(newColorDrawable(Color.Blue));
Chetan Ansel
  • 398
  • 2
  • 20
  • When you wanna get runtime permission , alert dialog appears automatically. Alert dialog backgorund and text colors are white. This is problem. İ just wanna change alert dialog color to eliminate this problem – emowise Oct 08 '18 at 11:20
  • yes but: it says: can not resolve symbol: alertDialog – emowise Oct 08 '18 at 11:30
  • instead alertdialog use your local instance name of Alert dialog class that u have used.. – Chetan Ansel Oct 08 '18 at 11:37
  • I am new on android. Can you write the code? İ tried this but not working new AlertDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.Blue)); – emowise Oct 08 '18 at 11:41
  • please check the updated code, it will works for you. – Chetan Ansel Oct 08 '18 at 11:42
  • I dont use alert dialog like this. I wanna change alert dialog backgorund that seems automatically. It means i dont write code for alert dialog – emowise Oct 08 '18 at 11:48
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/181476/discussion-between-chetan-ansel-and-emre-ugur). – Chetan Ansel Oct 08 '18 at 11:53
0

You want to change runtime permission request dialog colors I suppose. You can't customize those alert dialogs. They are default.

Take a look into this answer: How can I customize permission dialog in Android?