Hide and display popupwindow in Android (showatlocation/showasdropdown)

Source: Internet
Author: User

reprint: http://orgcent.com/android-popupwindow-showasdropdown-showatlocation/

the previous article details the usage of popupwindow (Position, animation, and focus). For details, see the usage of popupwindow in Android (Position, animation, and focus ). The following describes how to hide, display, and display position (showatlocation/showasdropdown) of popupwindow ).

1. Hide popupwindow

1
2
3
4
Final   Popupwindow window   =   Mpagestatwin ;
If ( Null   ! =   Window   &&   Window. Isshowing ( ) )   {
Win. Dismiss ( ) ;
}

2. Display and Position Setting of popupwindow

1 Window.Showatlocation ( Parent, gravity. Right   |   Gravity. Bottom ,   10 , 10 ) ;
The first parameter specifies the popupwindow anchor view, that is, the view to which the popupwindow is attached.
The second parameter specifies the starting point as the bottom right corner of the parent, and the third parameter sets the source point as the bottom right corner of the parent, with each offset of 10 pixels to the left and top.
1
2
3
4
// Use popupwindow as the anchor drop-down window. It is displayed in the lower left corner of anchor.
Window. Showasdropdown ( Anchor) ;
// Xoff, yoff offset based on the lower left corner of anchor.
Window. Showasdropdown ( Anchor, xoff, yoff ) ;
If there is not enough space to display popupwindow, the lower left corner of popupwindow will be displayed in the upper left corner of anchor.
Related Article

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.