android dialog coordinate location, layout file, key blocker

Source: Internet
Author: User

Dialog Mydialog = new Dialog (this);        Setcontentview can set the view can also be a layout file Mydialog.setcontentview (R.layout.test_akey);        Window Dialogwindow = Mydialog.getwindow ();        Windowmanager.layoutparams LP = Dialogwindow.getattributes (); Dialogwindow.setgravity (Gravity.left |        Gravity.top); Gets the current window WindowManager mwindowmanager= (windowmanager) getapplication (). Getsystemservice (Getapplication ().          Window_service); lp.x = 200; X-coordinate lp.y = 200; The y-coordinate (depending on the window size, for example, half of the height of the window mwindowmanager.getdefaultdisplay (). GetHeight ()/2) Lp.width = WindowManager.LayoutParams.WRAP _content; width lp.height = WindowManager.LayoutParams.WRAP_CONTENT; Height lp.alpha = 0.8f;        Transparency////Click Elsewhere to disappear mydialog.setcancelable (true);        Dialogwindow.setattributes (LP);            Rewrite Onkeylistener, where you can intercept keystrokes Mydialog.setonkeylistener (new Onkeylistener () {@Override public boolean OnKey (dialoginterface Mydialog, int keycode, keyevent event) {if (keycode==keyevent.keycode_back) {//Intercept return key                return true;            } else return false;        }        });         Gets the control in Dialog button mtest_btn = (button) Mydialog.findviewbyid (R.ID.TEST_BTN); Mydialog.show ();//Display Dialog Mydialog.dismiss ();//Close Dialog







android dialog coordinate location, layout file, key blocker

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.