I want to create a custom dialog box like below
I have tried the foll
Simple first create a class
public class ViewDialog {
public void showDialog(Activity activity, String msg){
final Dialog dialog = new Dialog(activity);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCancelable(false);
dialog.setContentView(R.layout.custom_dialogbox_otp);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
TextView text = (TextView) dialog.findViewById(R.id.txt_file_path);
text.setText(msg);
Button dialogBtn_cancel = (Button) dialog.findViewById(R.id.btn_cancel);
dialogBtn_cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Toast.makeText(getApplicationContext(),"Cancel" ,Toast.LENGTH_SHORT).show();
dialog.dismiss();
}
});
Button dialogBtn_okay = (Button) dialog.findViewById(R.id.btn_okay);
dialogBtn_okay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Toast.makeText(getApplicationContext(),"Okay" ,Toast.LENGTH_SHORT).show();
dialog.cancel();
}
});
dialog.show();
}
}
then create a custom_dialogbox_otp
then in your drawable create beneath xml files.
for round_layout_white_otp.xml
for round_layout_otp.xml
round_button
Then finally use the underneath code to visual ur dialog :)
ViewDialog alert = new ViewDialog();
alert.showDialog(ReceivingOTPRegActivity.this, "OTP has been sent to your Mail ");
your output :)