PopupWindow的属性及用法

本文详细介绍了PopupWindow的各种属性和用法,包括构造方法、API调用,如设置内容、宽高、焦点等。还展示了如何在指定位置显示PopupWindow,并给出了在控件下方以动画方式进出的示例代码。通过设置动画资源和style,实现了PopupWindow平滑的显示和消失效果。
摘要由CSDN通过智能技术生成
PopupWindow可实现弹窗效果,但是,Popupwidow没有默认布局,需要我们自己设置。
一.PopupWindow的API
构造方法摘要
PopupWindow() 
          Create a new empty, non focusable popup window of dimension (0,0).
 //创建一个空的、没有获取焦点的、长宽尺寸均为0的popup window
PopupWindow(Context context) 
          Create a new empty, non focusable popup window of dimension (0,0).
 //创建一个空的、没有获取焦点的、长宽尺寸均为0的popup window
PopupWindow(Context context, AttributeSet attrs) 
          Create a new empty, non focusable popup window of dimension (0,0).
 //创建一个空的、没有获取焦点的、长宽尺寸均为0的popup window
PopupWindow(Context context, AttributeSet attrs, int defStyle) 
          Create a new empty, non focusable popup window of dimension (0,0).
 //创建一个空的、没有获取焦点的、长宽尺寸均为0的popup window
PopupWindow(int width, int height) 
          Create a new empty, non focusable popup window.
 //创建一个没有获取焦点的、宽为width长为height的popup window
PopupWindow(View contentView) 
          Create a new non focusable popup window which can display the contentView.
 //创建一个没有获取焦点的、显示contentView的popup window
PopupWindow(View contentView, int width, int height) 
          Create a new non focusable popup window which can display the contentView.
 //创建一个没有获取焦点的、宽为width长为height显示contentView的popup window
PopupWindow(View contentView, int width, int height, boolean focusable) 
          Create a new popup window which can display the contentView.
 //创建一个根据focusable来判断是否获取焦点的、宽为width长为height显示contentView的popup window
方法摘要
 void dismiss() 
          Dispose of the popup window.
 //使popup window消失
 int getAnimationStyle() 
          Return the animation style to use the popup appears and disappears
 //返回该popup window出现或消失的动画类型,返回值为整型
 Drawable getBackground() 
          Return the drawable used as the popup window's background.
 //返回popup window的背景,返回值为Drawable类型
 View getContentView() 
          Return the view used as the content of the popup window.
 //返回popup window展示的内容,返回值为一个View
 int getHeight() 
          Return this popup's height MeasureSpec
 //返回该popup window的高度值,返回值为int型
 int getInputMethodMode() 
          Return the current value in setInputMethodMode(int).
 //返回当前popup window对输入法的设置模式
 int getMaxAvailableHeight(View anchor) 
          Returns the maximum height that is available for the popup to be completely shown.
 //返回能使当前popup window完整显示的最大高度
 int getMaxAvailableHeight(View anchor, int yOffset) 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值