Advertisement
Guest User

custom dialog with window setting configured to wrap content

a guest
Aug 28th, 2015
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. Dialog dialog = new Dialog(this);
  2. dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
  3.  
  4.  
  5.        
  6.         WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
  7.         Window window = dialog.getWindow();
  8.         lp.copyFrom(window.getAttributes());       
  9.         //This makes the dialog take up the full width
  10.         lp.width = WindowManager.LayoutParams.WRAP_CONTENT;
  11.         lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
  12.         window.setAttributes(lp);
  13.  
  14.         dialog.setContentView(R.layout.custom_dialog);
  15.  
  16.         Button btnPositive=(Button) dialog.findViewById(R.id.btnPositive);
  17.         Button btnNegative=(Button) dialog.findViewById(R.id.btnNegative);
  18.         Button btnNeutral=(Button) dialog.findViewById(R.id.btnNeutral);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement