Skip to content
Advertisement

How to make a the dialog choose box like this custom dialog with cancel button on the top right corner like this one?

How to make a the dialog choose box like this custom dialog with cancel button on the top right corner and lines with different lengths and floating hint when there is chosen anything in android studio.enter image description here

Advertisement

Answer

To display the required dialog box top right of the screen use this code :

Window window = alertdialog.getWindow();
            WindowManager.LayoutParams wlp = window.getAttributes();
            wlp.gravity = Gravity.TOP | Gravity.RIGHT;
            wlp.width = ViewGroup.LayoutParams.MATCH_PARENT;
            wlp.y=100 ;  //if you want give margin from top
            //wlp.x=100 ;    //if you want give margin from left
            wlp.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND;
            window.setAttributes(wlp); 
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement