Android Popupwindow appears above or below the control

Source: Internet
Author: User

Implemented in projects

Android Popupwindow appears above or below the control


The main code is as follows




View view = Minflater.inflate (R.layout.layout_popupwindow, NULL);
Popupwindowlayout popupwindowlayout = (popupwindowlayout) View.findviewbyid (R.id.llayout_popupwindow);
Popupwindowlayout.initviews (Mcontext, titles, false);
Final Popupwindow Popupwindow = new Popupwindow (view, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
View.measure (measurespec.unspecified, measurespec.unspecified);
int popupwidth = View.getmeasuredwidth ();
int popupheight = View.getmeasuredheight ();
int[] location = new INT[2];
Allow click outside to disappear
Popupwindow.setbackgrounddrawable (New bitmapdrawable ());
Popupwindow.setoutsidetouchable (TRUE);
Popupwindow.setfocusable (TRUE);
Get location
V.getlocationonscreen (location);
Popupwindow.setanimationstyle (R.style.mypopwindow_anim_style);
Popupwindow.showatlocation (V, gravity.no_gravity, (location[0] + v.getwidth ()/2)-POPUPWIDTH/2, location[1]-popupHe ight);



Photo and demo Download link Download complete demo click Open link

Android Popupwindow appears above or below the control

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.