I have in my code setInverseBackgroundForced set to true, but it doesn't appear to work. The code produces white text on a dark background.
Here is my builder code:
public class test {
private void createMyLocationDisabledAlert() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Title")
.setInverseBackgroundForced(true)
.setMessage(
"my message")
.setCancelable(false)
.setPositiveButton("Options",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
showOptions();
}
});
builder.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
}
}
What could I be doing wrong? I have tried the method call in different positions of the code block but to no resolve.
setInverseBackgroundForced (boolean useInverseBackground) is deprecated in Android API level 23 (Android 6.0 Marshmallow).
This flag is only used for pre-Material themes. Instead, specify the window background using on the alert dialog theme.
Code is like this!
AlertDialog dialog = new AlertDialog.Builder(BaseActivity.this, R.style.Dark2).create();
dialog.getWindow().setBackgroundDrawableResource(android.R.color.background_dark);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With