Popupwindow显示的问题

public  PopupWindow   (View   contentView, int width, int height)
Since:   API Level 1

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.

Parameters
contentView width height
the popup's content
the popup's width
the popup's height
public  PopupWindow   (View   contentView)
Since:   API Level 1

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.

Parameters
contentView
the popup's content

当然你也可以再后面初始化popupWindow时,再调用其他功能函数进行设置。

窗体显示函数:

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)

Display the content view in a popup window anchored to the bottom-left corner of the anchor view.

void showAtLocation (View   parent, int gravity, int x, int y)

Display the content view in a popup window at the specified location.

具体就两种方式:showAsDropDown 和 showAtLocation ,

 

showAsDropDown

 

showAtLocation   

  •  自定义弹出的位置,参数列里有parent,与 showAsDropDown的 anchor不同性质,注释里是这样说的: a parent view to get the  getWindowToken()   token from,也就是与弹出的位置没有直接关联;但是这个parent必须是一个activityl里的View,不然会出错
  •  参数gravity,大致与TextView的gravity一样,指示控件的对齐方向,当然这里的基准对象当然是DisplayWindow啦;
  •  参数 x,y 就是指示弹出窗实际的显示坐标了,但这两个参数依赖参数gravity,指示基准对齐后的xy偏移值,这点与showAsDropDown 的一样


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值