Guest User

Untitled

a guest
Jan 24th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. AlertDialog.Builder builder = new AlertDialog.Builder(context.getApplicationContext());
  2. LayoutInflater inflater = LayoutInflater.from(context);
  3. View dialogView = inflater.inflate(R.layout.caller_dialog, null);
  4.  
  5. ImageView button = dialogView.findViewById(R.id.close_btn);
  6. builder.setView(dialogView);
  7. final AlertDialog alert = builder.create();
  8. alert.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
  9. alert.getWindow().setType(WindowManager.LayoutParams.TYPE_PHONE);
  10. alert.setCanceledOnTouchOutside(true);
  11. alert.show();
  12. WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
  13. Window window = alert.getWindow();
  14. window.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
  15. window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
  16. window.setGravity(Gravity.TOP);
  17. lp.copyFrom(window.getAttributes());
  18. //This makes the dialog take up the full width
  19. lp.width = WindowManager.LayoutParams.MATCH_PARENT;
  20. lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
  21. window.setAttributes(lp);
  22. button.setOnClickListener(new View.OnClickListener() {
  23. @Override
  24. public void onClick(View view) {
  25. //close the service and remove the from from the window
  26. alert.dismiss();
  27. }
  28. });
Add Comment
Please, Sign In to add comment