Android英文文档翻译系列(4)——PopupWindow

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

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

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 
时间: 2024-10-28 19:51:13

Android英文文档翻译系列(4)——PopupWindow的相关文章

Android英文文档翻译系列(1)——AlarmManager

原文:个人翻译,水平有限,欢迎看官指正. public class AlarmManager extends Object java.lang.Object    ? android.app.AlarmManager Class Overview This class provides access to the system alarm services. 这个类可以提供访问系统闹钟服务, These allow you to schedule your application to be r

Android英文文档翻译系列(5)——VPNService

API14位于android.net.VpnService 类概述|Class OverviewVpnService is a base class for applications to extend and build their own VPN solutions//VpnService一个为应用程序扩展和建立自己的VPN解决方案的基类.In general, it creates a virtual network interface, configures addresses and

Android英文文档翻译系列(6)——LocalBroadcastManager

public class LocalBroadcastManager extends Object java.lang.Object    ? android.support.v4.content.LocalBroadcastManager Class Overview Helper to register for and send broadcasts of Intents to local objects within your process. This is has a number o

Android英文文档翻译系列(5)——Creating Lists and Cards[创建List和卡片,CardView和RecyclerView]

Creating Lists and Cards To create complex lists and cards with material design styles in your apps, you can use the RecyclerView and CardView widgets. Create Lists The RecyclerView widget is a more advanced and flexible version of ListView. This wid

Android英文文档翻译系列(3)——AsyncTask

AsyncTask——异步任务 个人认为这是翻译比较好的一次.. Class Overview//类概述 AsyncTask enables proper and easy use of the UI thread. This class allows to perform background operations and publish results on the UI thread without having to manipulate threads and/or handlers.

Android英文文档翻译系列(2)——HandlerThread

public class HandlerThread extends Thread Class  Overview Handy class for starting a new thread that has a looper.The looper can than be used to create handler classes.Note that start() mast still not called. Handy class for starting a new thread tha

(android高仿系列)今日头条 --新闻阅读器 (三) 完结 、总结 篇

从写第一篇今日头条高仿系列开始,到现在已经过去了1个多月了,其实大体都做好了,就是迟迟没有放出来,因为我觉得,做这个东西也是有个过程的,我想把这个模仿中一步一步学习的过程,按照自己的思路写下来,在根据碰到的知识点和问题,并且罗列出这些东西的知识点和使用方法.如果你单纯的把做好的一个DEMO拿去改改用用,那样,你永远不知道里面用到的内容是涉及到什么知识点,用什么方法实现,那样就没有多少提升价值而言了. 近期都是在通过开发文档把以前的一些东西重新过一遍,看好多网友都催促想要新版本的,那我就在这里先把

Android 源码系列之<十三>从源码的角度深入理解LeakCanary的内存泄露检测机制(中)

转载请注明出处:http://blog.csdn.net/llew2011/article/details/52958563 在上篇文章Android 源码系列之<十二>从源码的角度深入理解LeakCanary的内存泄露检测机制(上)中主要介绍了Java内存分配相关的知识以及在Android开发中可能遇见的各种内存泄露情况并给出了相对应的解决方案,如果你还没有看过上篇文章,建议点击这里阅读一下,这篇文章我将要向大家介绍如何在我们的应用中使用square开源的LeakCanary库来检测应用中出

Android网络编程系列 一 TCP/IP协议族

在学习和使用Android网路编程时,我们接触的仅仅是上层协议和接口如Apache的httpclient或者Android自带的httpURlconnection等等.对于这些接口的底层实现我们也有必要进一步的了解,这就要我们了解网络通信层了,提到网络通信层不得不说起ISO-OSI的七层协议经典架构,如图所示: 上图的左边部分就是osi架构模型了, ISO/OSI模型,即开放式通信系统互联参考模型(Open System Interconnection Reference Model),是国际标