PopupWindow在官方文档中是这么描述的:
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.
翻译过来就是:PopupWindow表示可以用来显示任意视图的弹出窗口。弹出窗口是一个浮动的容器,它出现在当前活动的顶部。
简单来说就是一个弹窗。
如:
首先我们先来看看PopupWindow的各个属性方法
PopupWindow的XML的属性
android:overlapAnchor //弹出窗口是否应该重叠它的锚视图。
android:popupAnimationStyle //用于弹出窗口的动画样式
android:popupBackground //用于弹出窗口的背景。
android:popupElevation //窗口高度用于弹出窗口。
android:popupEnterTransition //用来将视图移动到弹出窗口的过渡
android:popupExitTransition //用于将视图移出弹出窗口的过渡
PopupWindow常用的构造方法:
PopupWindow(Context context) //参数为上下文,创建一个高宽为0 的新的没有焦点的PopupWindow
PopupWindow() //创建一个高宽为0的新的没有焦点的PopupWindow
PopupWindow(View contentView) //参数为要显示的View,就是PopupWindow所要显示的视图
PopupWindow(int width, int height) //参数为要显示的View的宽度和高度
PopupWindow(View contentView, int width, int height) //参数为要显示的