public class PopupWindow extends Object
This class represents a popup window that can be used to display an arbitrary view. The popup window is a floating container that appears on top of the current activity.
On all versions of Android, popup window enter and exit animations may be
specified by calling setAnimationStyle(int)
and passing the
resource ID for an animation style that defines windowEnterAnimation
and windowExitAnimation
. For example, passing
android.R.style#Animation_Dialog
will give a scale and alpha
animation.
A window animation style may also be specified in the popup window's style
XML via the popupAnimationStyle
attribute.
Starting with API 23, more complex popup window enter and exit transitions
may be specified by calling either setEnterTransition(Transition)
or setExitTransition(Transition)
and passing a Transition
.
Popup enter and exit transitions may also be specified in the popup window's
style XML via the popupEnterTransition
and popupExitTransition
attributes, respectively.
AutoCompleteTextView
,
Spinner
Modifier and Type | Class and Description |
---|---|
static interface |
PopupWindow.OnDismissListener
Listener that is called when this popup window is dismissed.
|
Modifier and Type | Field and Description |
---|---|
static int |
INPUT_METHOD_FROM_FOCUSABLE
Mode for
setInputMethodMode(int) : the requirements for the
input method should be based on the focusability of the popup. |
static int |
INPUT_METHOD_NEEDED
Mode for
setInputMethodMode(int) : this popup always needs to
work with an input method, regardless of whether it is focusable. |
static int |
INPUT_METHOD_NOT_NEEDED
Mode for
setInputMethodMode(int) : this popup never needs to
work with an input method, regardless of whether it is focusable. |
Constructor and Description |
---|
PopupWindow()
Create a new empty, non focusable popup window of dimension (0,0).
|
PopupWindow(Context context)
Create a new empty, non focusable popup window of dimension (0,0).
|
PopupWindow(Context context,
AttributeSet attrs)
Create a new empty, non focusable popup window of dimension (0,0).
|
PopupWindow(Context context,
AttributeSet attrs,
int defStyleAttr)
Create a new empty, non focusable popup window of dimension (0,0).
|
PopupWindow(Context context,
AttributeSet attrs,
int defStyleAttr,
int defStyleRes)
Create a new, empty, non focusable popup window of dimension (0,0).
|
PopupWindow(int width,
int height)
Create a new empty, non focusable popup window.
|
PopupWindow(View contentView)
Create a new non focusable popup window which can display the
contentView.
|
PopupWindow(View contentView,
int width,
int height)
Create a new non focusable popup window which can display the
contentView.
|
PopupWindow(View contentView,
int width,
int height,
boolean focusable)
Create a new popup window which can display the contentView.
|
Modifier and Type | Method and Description |
---|---|
void |
dismiss()
Disposes of the popup window.
|
int |
getAnimationStyle()
Return the animation style to use the popup appears and disappears
|
Drawable |
getBackground()
Return the drawable used as the popup window's background.
|
View |
getContentView()
Return the view used as the content of the popup window.
|
float |
getElevation() |
Transition |
getEnterTransition()
Returns the enter transition to be used when the popup window is shown.
|
Transition |
getExitTransition()
Returns the exit transition to be used when the popup window is
dismissed.
|
int |
getHeight()
Returns the popup's requested height.
|
int |
getInputMethodMode()
Return the current value in
setInputMethodMode(int) . |
int |
getMaxAvailableHeight(View anchor)
Returns the maximum height that is available for the popup to be
completely shown.
|
int |
getMaxAvailableHeight(View anchor,
int yOffset)
Returns the maximum height that is available for the popup to be
completely shown.
|
int |
getMaxAvailableHeight(View anchor,
int yOffset,
boolean ignoreBottomDecorations)
Returns the maximum height that is available for the popup to be
completely shown, optionally ignoring any bottom decorations such as
the input method.
|
boolean |
getOverlapAnchor()
Returns whether the popup window should overlap its anchor view when
displayed as a drop-down.
|
int |
getSoftInputMode()
Returns the current value in
setSoftInputMode(int) . |
int |
getWidth()
Returns the popup's requested width.
|
int |
getWindowLayoutType()
Returns the layout type for this window.
|
boolean |
isAboveAnchor()
Indicates whether the popup is showing above (the y coordinate of the popup's bottom
is less than the y coordinate of the anchor) or below the anchor view (the y coordinate
of the popup is greater than y coordinate of the anchor's bottom).
|
boolean |
isAttachedInDecor()
Indicates whether the popup window will be attached in the decor frame of its parent
window.
|
boolean |
isClippingEnabled()
Indicates whether clipping of the popup window is enabled.
|
boolean |
isFocusable()
Indicate whether the popup window can grab the focus.
|
boolean |
isLayoutInScreenEnabled()
Indicates whether the popup window will be forced into using absolute screen coordinates
for positioning.
|
boolean |
isOutsideTouchable()
Indicates whether the popup window will be informed of touch events
outside of its window.
|
boolean |
isShowing()
Indicate whether this popup window is showing on screen.
|
boolean |
isSplitTouchEnabled()
Indicates whether the popup window supports splitting touches.
|
boolean |
isTouchable()
Indicates whether the popup window receives touch events.
|
void |
setAnimationStyle(int animationStyle)
Change the animation style resource for this popup.
|
void |
setAttachedInDecor(boolean enabled)
This will attach the popup window to the decor frame of the parent window to avoid
overlaping with screen decorations like the navigation bar.
|
void |
setBackgroundDrawable(Drawable background)
Specifies the background drawable for this popup window.
|
void |
setClippingEnabled(boolean enabled)
Allows the popup window to extend beyond the bounds of the screen.
|
void |
setClipToScreenEnabled(boolean enabled)
Clip this popup window to the screen, but not to the containing window.
|
void |
setContentView(View contentView)
Change the popup's content.
|
void |
setElevation(float elevation)
Specifies the elevation for this popup window.
|
void |
setEnterTransition(Transition enterTransition)
Sets the enter transition to be used when the popup window is shown.
|
void |
setEpicenterBounds(Rect bounds)
Sets the bounds used as the epicenter of the enter and exit transitions.
|
void |
setExitTransition(Transition exitTransition)
Sets the exit transition to be used when the popup window is dismissed.
|
void |
setFocusable(boolean focusable)
Changes the focusability of the popup window.
|
void |
setHeight(int height)
Sets the popup's requested height.
|
void |
setIgnoreCheekPress()
Set the flag on popup to ignore cheek press events; by default this flag
is set to false
which means the popup will not ignore cheek press dispatch events.
|
void |
setInputMethodMode(int mode)
Control how the popup operates with an input method: one of
INPUT_METHOD_FROM_FOCUSABLE , INPUT_METHOD_NEEDED ,
or INPUT_METHOD_NOT_NEEDED . |
void |
setLayoutInScreenEnabled(boolean enabled)
Allows the popup window to force the flag
WindowManager.LayoutParams#FLAG_LAYOUT_IN_SCREEN , overriding default behavior. |
void |
setLayoutInsetDecor(boolean enabled)
Allows the popup window to force the flag
WindowManager.LayoutParams#FLAG_LAYOUT_INSET_DECOR , overriding default behavior. |
void |
setOnDismissListener(PopupWindow.OnDismissListener onDismissListener)
Sets the listener to be called when the window is dismissed.
|
void |
setOutsideTouchable(boolean touchable)
Controls whether the pop-up will be informed of touch events outside
of its window.
|
void |
setOverlapAnchor(boolean overlapAnchor)
Sets whether the popup window should overlap its anchor view when
displayed as a drop-down.
|
void |
setSoftInputMode(int mode)
Sets the operating mode for the soft input area.
|
void |
setSplitTouchEnabled(boolean enabled)
Allows the popup window to split touches across other windows that also
support split touch.
|
void |
setTouchable(boolean touchable)
Changes the touchability of the popup window.
|
void |
setTouchInterceptor(View.OnTouchListener l)
Set a callback for all touch events being dispatched to the popup
window.
|
void |
setTouchModal(boolean touchModal)
Set whether this window is touch modal or if outside touches will be sent to
other windows behind it.
|
void |
setWidth(int width)
Sets the popup's requested width.
|
void |
setWindowLayoutMode(int widthSpec,
int heightSpec)
Deprecated.
Use
setWidth(int) and setHeight(int) . |
void |
setWindowLayoutType(int layoutType)
Set the layout type for this window.
|
void |
showAsDropDown(View anchor)
Display the content view in a popup window anchored to the bottom-left
corner of the anchor view.
|
void |
showAsDropDown(View anchor,
int xoff,
int yoff)
Display the content view in a popup window anchored to the bottom-left
corner of the anchor view offset by the specified x and y coordinates.
|
void |
showAsDropDown(View anchor,
int xoff,
int yoff,
int gravity)
Displays the content view in a popup window anchored to the corner of
another view.
|
void |
showAtLocation(IBinder token,
int gravity,
int x,
int y)
Display the content view in a popup window at the specified location.
|
void |
showAtLocation(View parent,
int gravity,
int x,
int y)
Display the content view in a popup window at the specified location.
|
void |
update()
Updates the state of the popup window, if it is currently being displayed,
from the currently set state.
|
void |
update(int width,
int height)
Updates the dimension of the popup window.
|
void |
update(int x,
int y,
int width,
int height)
Updates the position and the dimension of the popup window.
|
void |
update(int x,
int y,
int width,
int height,
boolean force)
Updates the position and the dimension of the popup window.
|
void |
update(View anchor,
int width,
int height)
Updates the position and the dimension of the popup window.
|
void |
update(View anchor,
int xoff,
int yoff,
int width,
int height)
Updates the position and the dimension of the popup window.
|
public static final int INPUT_METHOD_FROM_FOCUSABLE
setInputMethodMode(int)
: the requirements for the
input method should be based on the focusability of the popup. That is
if it is focusable than it needs to work with the input method, else
it doesn't.public static final int INPUT_METHOD_NEEDED
setInputMethodMode(int)
: this popup always needs to
work with an input method, regardless of whether it is focusable. This
means that it will always be displayed so that the user can also operate
the input method while it is shown.public static final int INPUT_METHOD_NOT_NEEDED
setInputMethodMode(int)
: this popup never needs to
work with an input method, regardless of whether it is focusable. This
means that it will always be displayed to use as much space on the
screen as needed, regardless of whether this covers the input method.public PopupWindow(Context context)
Create a new empty, non focusable popup window of dimension (0,0).
The popup does provide a background.
public PopupWindow(Context context, AttributeSet attrs)
Create a new empty, non focusable popup window of dimension (0,0).
The popup does provide a background.
public PopupWindow(Context context, AttributeSet attrs, int defStyleAttr)
Create a new empty, non focusable popup window of dimension (0,0).
The popup does provide a background.
public PopupWindow(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
Create a new, empty, non focusable popup window of dimension (0,0).
The popup does not provide a background.
public PopupWindow()
Create a new empty, non focusable popup window of dimension (0,0).
The popup does not provide any background. This should be handled by the content view.
public PopupWindow(View contentView)
Create a new non focusable popup window which can display the contentView. The dimension of the window are (0,0).
The popup does not provide any background. This should be handled by the content view.
contentView
- the popup's contentpublic PopupWindow(int width, int height)
Create a new empty, non focusable popup window. The dimension of the window must be passed to this constructor.
The popup does not provide any background. This should be handled by the content view.
width
- the popup's widthheight
- the popup's heightpublic PopupWindow(View contentView, int width, int height)
Create a new non focusable popup window which can display the contentView. The dimension of the window must be passed to this constructor.
The popup does not provide any background. This should be handled by the content view.
contentView
- the popup's contentwidth
- the popup's widthheight
- the popup's heightpublic PopupWindow(View contentView, int width, int height, boolean focusable)
Create a new popup window which can display the contentView. The dimension of the window must be passed to this constructor.
The popup does not provide any background. This should be handled by the content view.
contentView
- the popup's contentwidth
- the popup's widthheight
- the popup's heightfocusable
- true if the popup can be focused, false otherwisepublic void setEnterTransition(Transition enterTransition)
enterTransition
- the enter transition, or null
to cleargetEnterTransition()
public Transition getEnterTransition()
null
if not setsetEnterTransition(Transition)
public void setExitTransition(Transition exitTransition)
exitTransition
- the exit transition, or null
to cleargetExitTransition()
public Transition getExitTransition()
null
if not setsetExitTransition(Transition)
public void setEpicenterBounds(Rect bounds)
Transitions use a point or Rect, referred to as the epicenter, to orient the direction of travel. For popup windows, the anchor view bounds are used as the default epicenter.
See Transition.setEpicenterCallback(EpicenterCallback)
for more
information about how transition epicenters.
bounds
- the epicenter bounds relative to the anchor view, or
null
to use the default epicentergetTransitionEpicenter()
public Drawable getBackground()
null
if not setsetBackgroundDrawable(Drawable)
public void setBackgroundDrawable(Drawable background)
null
.background
- the popup's backgroundgetBackground()
public float getElevation()
setElevation(float)
public void setElevation(float elevation)
elevation
- the popup's elevation in pixelsgetElevation()
public int getAnimationStyle()
Return the animation style to use the popup appears and disappears
public void setIgnoreCheekPress()
If the popup is showing, calling this method will take effect only
the next time the popup is shown or through a manual call to one of
the update()
methods.
update()
public void setAnimationStyle(int animationStyle)
Change the animation style resource for this popup.
If the popup is showing, calling this method will take effect only
the next time the popup is shown or through a manual call to one of
the update()
methods.
animationStyle
- animation style to use when the popup appears
and disappears. Set to -1 for the default animation, 0 for no
animation, or a resource identifier for an explicit animation.update()
public View getContentView()
Return the view used as the content of the popup window.
View
representing the popup's contentsetContentView(android.view.View)
public void setContentView(View contentView)
Change the popup's content. The content is represented by an instance
of View
.
This method has no effect if called when the popup is showing.
contentView
- the new content for the popupgetContentView()
,
isShowing()
public void setTouchInterceptor(View.OnTouchListener l)
public boolean isFocusable()
Indicate whether the popup window can grab the focus.
setFocusable(boolean)
public void setFocusable(boolean focusable)
Changes the focusability of the popup window. When focusable, the
window will grab the focus from the current focused widget if the popup
contains a focusable View
. By default a popup
window is not focusable.
If the popup is showing, calling this method will take effect only
the next time the popup is shown or through a manual call to one of
the update()
methods.
focusable
- true if the popup should grab focus, false otherwise.isFocusable()
,
isShowing()
,
update()
public int getInputMethodMode()
setInputMethodMode(int)
.setInputMethodMode(int)
public void setInputMethodMode(int mode)
INPUT_METHOD_FROM_FOCUSABLE
, INPUT_METHOD_NEEDED
,
or INPUT_METHOD_NOT_NEEDED
.
If the popup is showing, calling this method will take effect only
the next time the popup is shown or through a manual call to one of
the update()
methods.
getInputMethodMode()
,
update()
public void setSoftInputMode(int mode)
mode
- The desired mode, see
WindowManager.LayoutParams.softInputMode
for the full listWindowManager.LayoutParams.softInputMode
,
getSoftInputMode()
public int getSoftInputMode()
setSoftInputMode(int)
.public boolean isTouchable()
Indicates whether the popup window receives touch events.
setTouchable(boolean)
public void setTouchable(boolean touchable)
Changes the touchability of the popup window. When touchable, the window will receive touch events, otherwise touch events will go to the window below it. By default the window is touchable.
If the popup is showing, calling this method will take effect only
the next time the popup is shown or through a manual call to one of
the update()
methods.
touchable
- true if the popup should receive touch events, false otherwiseisTouchable()
,
isShowing()
,
update()
public boolean isOutsideTouchable()
Indicates whether the popup window will be informed of touch events outside of its window.
setOutsideTouchable(boolean)
public void setOutsideTouchable(boolean touchable)
Controls whether the pop-up will be informed of touch events outside of its window. This only makes sense for pop-ups that are touchable but not focusable, which means touches outside of the window will be delivered to the window behind. The default is false.
If the popup is showing, calling this method will take effect only
the next time the popup is shown or through a manual call to one of
the update()
methods.
touchable
- true if the popup should receive outside
touch events, false otherwiseisOutsideTouchable()
,
isShowing()
,
update()
public boolean isClippingEnabled()
Indicates whether clipping of the popup window is enabled.
setClippingEnabled(boolean)
public void setClippingEnabled(boolean enabled)
Allows the popup window to extend beyond the bounds of the screen. By default the window is clipped to the screen boundaries. Setting this to false will allow windows to be accurately positioned.
If the popup is showing, calling this method will take effect only
the next time the popup is shown or through a manual call to one of
the update()
methods.
enabled
- false if the window should be allowed to extend outside of the screenisShowing()
,
isClippingEnabled()
,
update()
public void setClipToScreenEnabled(boolean enabled)
enabled
- True to clip to the screen.public boolean isSplitTouchEnabled()
Indicates whether the popup window supports splitting touches.
setSplitTouchEnabled(boolean)
public void setSplitTouchEnabled(boolean enabled)
Allows the popup window to split touches across other windows that also support split touch. When this flag is false, the first pointer that goes down determines the window to which all subsequent touches go until all pointers go up. When this flag is true, each pointer (not necessarily the first) that goes down determines the window to which all subsequent touches of that pointer will go until that pointer goes up thereby enabling touches with multiple pointers to be split across multiple windows.
enabled
- true if the split touches should be enabled, false otherwiseisSplitTouchEnabled()
public boolean isLayoutInScreenEnabled()
Indicates whether the popup window will be forced into using absolute screen coordinates for positioning.
public void setLayoutInScreenEnabled(boolean enabled)
Allows the popup window to force the flag
WindowManager.LayoutParams#FLAG_LAYOUT_IN_SCREEN
, overriding default behavior.
This will cause the popup to be positioned in absolute screen coordinates.
enabled
- true if the popup should always be positioned in screen coordinatespublic boolean isAttachedInDecor()
Indicates whether the popup window will be attached in the decor frame of its parent window.
setAttachedInDecor(boolean)
,
WindowManager.LayoutParams#FLAG_LAYOUT_ATTACHED_IN_DECOR
public void setAttachedInDecor(boolean enabled)
This will attach the popup window to the decor frame of the parent window to avoid
overlaping with screen decorations like the navigation bar. Overrides the default behavior of
the flag WindowManager.LayoutParams#FLAG_LAYOUT_ATTACHED_IN_DECOR
.
By default the flag is set on SDK version Build.VERSION_CODES#LOLLIPOP_MR1
or
greater and cleared on lesser SDK versions.
enabled
- true if the popup should be attached to the decor frame of its parent window.WindowManager.LayoutParams#FLAG_LAYOUT_ATTACHED_IN_DECOR
public void setLayoutInsetDecor(boolean enabled)
WindowManager.LayoutParams#FLAG_LAYOUT_INSET_DECOR
, overriding default behavior.
This will cause the popup to inset its content to account for system windows overlaying
the screen, such as the status bar.
This will often be combined with setLayoutInScreenEnabled(boolean)
.
enabled
- true if the popup's views should inset content to account for system windows,
the way that decor views behave for full-screen windows.public void setWindowLayoutType(int layoutType)
See WindowManager.LayoutParams#type
for possible values.
layoutType
- Layout type for this window.WindowManager.LayoutParams#type
public int getWindowLayoutType()
setWindowLayoutType(int)
public void setTouchModal(boolean touchModal)
@Deprecated public void setWindowLayoutMode(int widthSpec, int heightSpec)
setWidth(int)
and setHeight(int)
.Change the width and height measure specs that are given to the
window manager by the popup. By default these are 0, meaning that
the current width or height is requested as an explicit size from
the window manager. You can supply
ViewGroup.LayoutParams#WRAP_CONTENT
or
ViewGroup.LayoutParams#MATCH_PARENT
to have that measure
spec supplied instead, replacing the absolute width and height that
has been set in the popup.
If the popup is showing, calling this method will take effect only the next time the popup is shown.
widthSpec
- an explicit width measure spec mode, either
ViewGroup.LayoutParams#WRAP_CONTENT
,
ViewGroup.LayoutParams#MATCH_PARENT
, or 0 to use the absolute
width.heightSpec
- an explicit height measure spec mode, either
ViewGroup.LayoutParams#WRAP_CONTENT
,
ViewGroup.LayoutParams#MATCH_PARENT
, or 0 to use the absolute
height.public int getHeight()
ViewGroup.LayoutParams.WRAP_CONTENT
or ViewGroup.LayoutParams.MATCH_PARENT
.
The actual size of the popup may depend on other factors such as clipping and window layout.
setHeight(int)
public void setHeight(int height)
ViewGroup.LayoutParams.WRAP_CONTENT
or ViewGroup.LayoutParams.MATCH_PARENT
.
The actual size of the popup may depend on other factors such as clipping and window layout.
If the popup is showing, calling this method will take effect the next time the popup is shown.
height
- the popup height in pixels or a layout constantgetHeight()
,
isShowing()
public int getWidth()
ViewGroup.LayoutParams.WRAP_CONTENT
or ViewGroup.LayoutParams.MATCH_PARENT
.
The actual size of the popup may depend on other factors such as clipping and window layout.
setWidth(int)
public void setWidth(int width)
ViewGroup.LayoutParams.WRAP_CONTENT
or ViewGroup.LayoutParams.MATCH_PARENT
.
The actual size of the popup may depend on other factors such as clipping and window layout.
If the popup is showing, calling this method will take effect the next time the popup is shown.
width
- the popup width in pixels or a layout constantgetWidth()
,
isShowing()
public void setOverlapAnchor(boolean overlapAnchor)
If the popup is showing, calling this method will take effect only the next time the popup is shown.
overlapAnchor
- Whether the popup should overlap its anchor.getOverlapAnchor()
,
isShowing()
public boolean getOverlapAnchor()
setOverlapAnchor(boolean)
public boolean isShowing()
Indicate whether this popup window is showing on screen.
public void showAtLocation(View parent, int gravity, int x, int y)
Display the content view in a popup window at the specified location. If the popup window
cannot fit on screen, it will be clipped. See WindowManager.LayoutParams
for more information on how gravity and the x and y parameters are related. Specifying
a gravity of Gravity.NO_GRAVITY
is similar to specifying
Gravity.LEFT | Gravity.TOP
.
parent
- a parent view to get the View.getWindowToken()
token fromgravity
- the gravity which controls the placement of the popup windowx
- the popup's x location offsety
- the popup's y location offsetpublic void showAtLocation(IBinder token, int gravity, int x, int y)
token
- Window token to use for creating the new windowgravity
- the gravity which controls the placement of the popup windowx
- the popup's x location offsety
- the popup's y location offsetpublic void showAsDropDown(View anchor)
anchor
- the view on which to pin the popup windowdismiss()
public void showAsDropDown(View anchor, int xoff, int yoff)
If the view later scrolls to move anchor
to a different
location, the popup will be moved correspondingly.
anchor
- the view on which to pin the popup windowxoff
- A horizontal offset from the anchor in pixelsyoff
- A vertical offset from the anchor in pixelsdismiss()
public void showAsDropDown(View anchor, int xoff, int yoff, int gravity)
If there is not enough room on screen to show the popup in its entirety, this method tries to find a parent scroll view to scroll. If no parent view can be scrolled, the specified vertical gravity will be ignored and the popup will anchor itself such that it is visible.
If the view later scrolls to move anchor
to a different
location, the popup will be moved correspondingly.
anchor
- the view on which to pin the popup windowxoff
- A horizontal offset from the anchor in pixelsyoff
- A vertical offset from the anchor in pixelsgravity
- Alignment of the popup relative to the anchordismiss()
public boolean isAboveAnchor()
showAsDropDown(android.view.View)
or showAsDropDown(android.view.View, int, int)
was invoked.public int getMaxAvailableHeight(View anchor)
anchor
- The view on which the popup window must be anchored.public int getMaxAvailableHeight(View anchor, int yOffset)
anchor
- The view on which the popup window must be anchored.yOffset
- y offset from the view's bottom edgepublic int getMaxAvailableHeight(View anchor, int yOffset, boolean ignoreBottomDecorations)
anchor
- The view on which the popup window must be anchored.yOffset
- y offset from the view's bottom edgeignoreBottomDecorations
- if true, the height returned will be
all the way to the bottom of the display, ignoring any
bottom decorationspublic void dismiss()
showAsDropDown(android.view.View)
has been executed. Failing
that, calling this method will have no effect.showAsDropDown(android.view.View)
public void setOnDismissListener(PopupWindow.OnDismissListener onDismissListener)
onDismissListener
- The listener.public void update()
This includes:
public void update(int width, int height)
Calling this function also updates the window with the current popup
state as described for update()
.
width
- the new width in pixels, must be >= 0 or -1 to ignoreheight
- the new height in pixels, must be >= 0 or -1 to ignorepublic void update(int x, int y, int width, int height)
Width and height can be set to -1 to update location only. Calling this
function also updates the window with the current popup state as
described for update()
.
x
- the new x locationy
- the new y locationwidth
- the new width in pixels, must be >= 0 or -1 to ignoreheight
- the new height in pixels, must be >= 0 or -1 to ignorepublic void update(int x, int y, int width, int height, boolean force)
Width and height can be set to -1 to update location only. Calling this
function also updates the window with the current popup state as
described for update()
.
x
- the new x locationy
- the new y locationwidth
- the new width in pixels, must be >= 0 or -1 to ignoreheight
- the new height in pixels, must be >= 0 or -1 to ignoreforce
- true
to reposition the window even if the specified
position already seems to correspond to the LayoutParams,
false
to only reposition if neededpublic void update(View anchor, int width, int height)
Calling this function also updates the window with the current popup
state as described for update()
.
anchor
- the popup's anchor viewwidth
- the new width in pixels, must be >= 0 or -1 to ignoreheight
- the new height in pixels, must be >= 0 or -1 to ignorepublic void update(View anchor, int xoff, int yoff, int width, int height)
Width and height can be set to -1 to update location only. Calling this
function also updates the window with the current popup state as
described for update()
.
If the view later scrolls to move anchor
to a different
location, the popup will be moved correspondingly.
anchor
- the popup's anchor viewxoff
- x offset from the view's left edgeyoff
- y offset from the view's bottom edgewidth
- the new width in pixels, must be >= 0 or -1 to ignoreheight
- the new height in pixels, must be >= 0 or -1 to ignore