Advertisement

Responsive Advertisement

Custom Alert Dialog

  • Here.. for R.style.CustomAlertDialog, You have to create some xml line in style xml file.. 
  • For @drawable/popup_background. You have to create resource file with same name and below code👇 

final AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this,R.style.CustomAlertDialog);

ViewGroup viewGroup = findViewById(android.R.id.content);
View dialogView = LayoutInflater.from(view.getContext()).inflate(R.layout.applyforleave_row, viewGroup, false);
builder.setView(dialogView);
final AlertDialog alertDialog = builder.create();
alertDialog.show();                         <?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CustomAlertDialog" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:windowBackground">@drawable/popup_background</item>
</style>

</resources>       <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF" />
<corners android:radius="6dp" />
</shape> 

Post a Comment

0 Comments