博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Android英文文档翻译系列(4)——PopupWindow
阅读量:7050 次
发布时间:2019-06-28

本文共 4763 字,大约阅读时间需要 15 分钟。

public class

PopupWindow

extends  Object //直接继承至Object
java.lang.Object
android.widget.PopupWindow
 //widget

Class Overview//概述
 A popup window that can be used to display an arbitrary view. The popup windows is a floating container that appears on top of the current activity.
//一个泡泡窗,可以展示任意的视图。它是一个悬浮的容器,出现在当前Acitvity的上面。
 public static interface //有一个回调接口

PopupWindow.OnDismissListener

android.widget.PopupWindow.OnDismissListener
 

Class Overview

Listener that is called when this popup window is dismissed. 

//当泡泡关闭的时候调用这个回调方法

Public Constructors //构造器
  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 defStyle)

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()

Create a new empty, non focusable popup window of dimension (0,0).

  PopupWindow(View contentView)

Create a new non focusable popup window which can display the contentView.

//创建一个 没有焦点可以展示contentView的泡泡

  PopupWindow(int width, int height)

Create a new empty, non focusable popup window.

  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.

 

 

 void android.widget. PopupWindow.setFocusable(boolean focusable)

 

public void setFocusable (boolean focusable)

Since:  API Level 1

 

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.

// 设置泡泡窗的焦点,当有焦点时,如果这个泡泡里面包含一个View,它将会抢占当前widget的焦点。默认的泡泡是没有焦点的。

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.

 //如果这个泡泡正在show,调用这个方法只有在下次泡泡展现的时候作用,或者通过手动的调用update()方法。

 

 

public void setOutsideTouchable (boolean touchable)

Since:  API Level 3

 

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.

// 控制这个泡泡窗在窗口外的触摸事件会不会通知到,这仅会让这个泡泡窗可以被触摸但是还是没有焦点,这将一意味着触摸到了窗口外面将会转交到底下的窗口。默认是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.

//这个方法也需要刷新才能及时生效。
 

public void showAsDropDown (View anchor, int xoff, int yoff)

Since:  API Level 1

 

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. 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 scroll view can be scrolled, the bottom-left corner of the popup is pinned at the top left corner of the anchor view.

//以参照物的左下为标准,偏移xy 

If the view later scrolls to move anchor to a different location, the popup will be moved correspondingly.

 

Parameters
anchor the view on which to pin the popup window
See Also
  • dismiss()

public void showAsDropDown (View anchor)

Since:  API Level 1

 

Display the content view in a popup window anchored to the bottom-left corner of the anchor view. 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 scroll view can be scrolled, the bottom-left corner of the popup is pinned at the top left corner of the anchor view.

//以参照物的左下为标准,不便宜

 

Parameters
anchor the view on which to pin the popup window
See Also
  • dismiss()

public void showAtLocation (View parent, int gravity, int x, int y)
// 父视图,Gravity,坐标

Since:  API Level 1

 

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 NO_GRAVITY is similar to specifying Gravity.LEFT | Gravity.TOP.

//在一个窗口里面按预设显示一个内容视图。如果这个泡泡窗不能适应屏幕,将只会显示部分。LayoutParams跟如何居中和坐标参数是有关系的。制定一个没有居中的的就像居左居右。

 

Parameters
parent a parent view to get the getWindowToken() token from
gravity the gravity which controls the placement of the popup window
x the popup's x location offset
y the popup's y location offset 
 

转载地址:http://jrsol.baihongyu.com/

你可能感兴趣的文章
在java中如何在非servlet的普通类中获取request、response、session
查看>>
Linux Rsync
查看>>
Redis实现消息队列
查看>>
2k8 32bit下载
查看>>
密码需要带特殊字符
查看>>
个人收集的java精品网站
查看>>
036 关于网站的UV分析
查看>>
zabbix监控网络的出入口流量
查看>>
webstorm 破解方式
查看>>
动画综合练习(延迟进入+页面向导+文本框抖动)
查看>>
Notepad++ JSON关键字自动提示
查看>>
全息科普1 【转】
查看>>
Git 撤消操作(分布式版本控制系统)
查看>>
导出表中数据为insert语句
查看>>
mysql中如何更新一个字段的值为它本身的值连接上一个字符串
查看>>
在Telerik for silverlight控件radtreeview中如何通过路径得到节点(转载)
查看>>
图像处理之拼接---图像拼接opencv
查看>>
【分享】博客美化(2)自定义博客样式细节
查看>>
字节对齐导致的iOS EXC_ARM_DA_ALIGN崩溃
查看>>
TCHAR和CHAR类型的互转
查看>>