I am using a custom style for my AlertDialog
s, but it is making them appear fullscreen. I've searched around, but I could only seem to find people wanting to make it fullscreen...
Here is my style
<style name="MyDialog" parent="AlertDialog.AppCompat">
<item name="android:background">@color/material_dark</item>
<item name="android:layout_height">100dp</item>
<item name="android:textColor">@color/accent</item>
<item name="android:textColorPrimary">@color/material_white</item>
</style>
And one of my AlertDialog
s.
AlertDialog alertDialog = new AlertDialog.Builder(this.getContext(), R.style.MyDialog)
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle(this.getContext().getResources().getString(R.string.reset) + "?")
.setMessage(this.getContext().getResources().getString(R.string.AreYouSure))
.setPositiveButton(getString(R.string.yes), (dialog, which) -> {
reset();
})
.setNegativeButton(getString(R.string.notReally), (dialog, which) ->{
//Do nothing
})
.show();
And this is what it looks like. I cannot figure out why it takes up the entire screen. It should look like an AlertDialog
just with custom colors.
AlertDialog generally consists of the main title, the message, and two buttons, technically termed as a positive button and a negative button. Both positive and negative buttons can be programmed to perform various actions. By default, the negative button lets close the AlertDialog without any additional lines of code.
AlertDialog is a lightweight version of a Dialog. This is supposed to deal with INFORMATIVE matters only, That's the reason why complex interactions with the user are limited. Dialog on the other hand is able to do even more complex things .
create(); alertDialog. show(); alertDialog. getWindow(). setLayout(600, 400); //Controlling width and height.
add <item name="android:windowIsFloating">true</item> to MyDialog style
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