Custom Alert Dialog with styles
AlertDialog with custom style
Add this to your module's build.gradle
file
allprojects { repositories { ... maven { url 'https://jitpack.io' } } }
Add this to your module's build.gradle
file
dependencies { implementation 'com.github.yeyintkoko1788:AlertDialog:v1.0.0' }
In your activity or fragment setup CustomAlertDialog
This method always returns a AlertDialog object, so you can customize the Alert much more.
CustomAlertDialog dialog = new CustomAlertDialog(this, style);
For style
parameter you can choose:
CustomAlertDialog.DialogStyle.DEFAULT CustomAlertDialog.DialogStyle.NO_ACTION_BAR CustomAlertDialog.DialogStyle.CURVE CustomAlertDialog.DialogStyle.FILL_STYLE
More Style will come soon
DEFAULT
dialog.setAlertTitle("Alert Title"); dialog.setAlertMessage("Alert message...");
onClickListener
dialog.setPositiveButton("Ok", new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(getApplicationContext(),"Positive Button Clicked",Toast.LENGTH_SHORT).show(); dialog.dismiss(); } }); dialog.setNegativeButton("Cancel", new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(getApplicationContext(),"Negative Button Clicked",Toast.LENGTH_SHORT).show(); dialog.cancel(); } });
dialog.setDialogType(CustomAlertDialog.DialogType.ERROR);Currently available type are:
CustomAlertDialog.DialogType.DEFAULT CustomAlertDialog.DialogType.ERROR CustomAlertDialog.DialogType.SUCCESS CustomAlertDialog.DialogType.INFO CustomAlertDialog.DialogType.WARNING
NO_ACTION_BAR
and FILL_STYLE
alert style you can set your own image drawable
along with image tint color if you don't want image tint you can simply set this attribute to 0
dialog.setDialogImage(getDrawable(R.drawable.alert),0); // no tint dialog.setDialogImage(getDrawable(R.drawable.alert),getResources().getColor(R.color.colorWhite)); //with tint
dialog.setImageSize(150,150);
create
and show
your alert Don't forget to add this two
dialog.create(); dialog.show();
This is my first library, so hope you guys enjoy its and feel free to give any suggesting.