简体   繁体   中英

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. 在此处输入图片说明

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); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM