Window API译文

public abstract class

Window

extends   Object
java.lang.Object
   ↳android.view.Window

Class Overview


Abstract base class for a top-level window look and behavior policy. An instance of this class should be used as the top-level view added to the window manager. It provides standard UI policies such as a background, title area, default key processing, etc.

The only existing implementation of this abstract class is android.policy.PhoneWindow, which you should instantiate when needing a Window. Eventually that class will be refactored and a factory method added for creating Window instances without knowing about a particular implementation

window是一个抽象基类,负责顶层窗口显示和行为的规则。这个类的一个实例必须被用作顶层的view加入到window manager中。它提供了标准UI规则,例如:背景,标题区域,默认的主进程等等。

这个抽象类的仅有的一个实现是android.policy.PhoneWindow。当你需要一个窗口window的时候,你需要实例化PhoneWindow。最后,PhoneWindow这个类会使用你不需要知道的特殊实现方式的重构方法进行重构,从而得到一个PhoneWindow对象,也即得到一个窗口。

Summary


Nested Classes内部类

interface

接口

Window.Callback

回调类

API from a Window back to its caller. 

应用程序编程接口:从窗口window到它的调用者

Constants
intDEFAULT_FEATURES窗口默认特征The default features enabled 启用
intFEATURE_ACTION_BARFlag for enabling the Action Bar.
intFEATURE_ACTION_BAR_OVERLAYFlag for requesting an Action Bar that overlays window content.
intFEATURE_ACTION_MODE_OVERLAYFlag for specifying the behavior of action modes when an Action Bar is not present.
intFEATURE_CONTEXT_MENU上下文菜单Flag for the context menu.
intFEATURE_CUSTOM_TITLE自定义标题Flag for custom title.
intFEATURE_INDETERMINATE_PROGRESS不确定的进度条Flag for indeterminate progress
intFEATURE_LEFT_ICON标题区域的左图标Flag for having an icon on the left side of the title bar
intFEATURE_NO_TITLE无标题Flag for the "no title" feature, turning off the title at the top of the screen.
intFEATURE_OPTIONS_PANEL选项面板Flag for the "options panel" feature.
intFEATURE_PROGRESS指示器进度条Flag for the progress indicator feature
intFEATURE_RIGHT_ICON标题区域的右图标Flag for having an icon on the right side of the title bar
intID_ANDROID_CONTENT布局Layout的IDThe ID that the main layout in the XML layout file should have.
intPROGRESS_END进度条的结束值Ending value for the (primary) progress
intPROGRESS_INDETERMINATE_OFF关闭不确定的进度条Flag for setting the progress bar's indeterminate mode off
int

PROGRESS_INDETERMINATE_ON开启不确定的进度条

Flag for setting the progress bar's indeterminate mode on
intPROGRESS_SECONDARY_END第二进度条的最高可能值Highest possible value for the secondary progress
intPROGRESS_SECONDARY_START第二进度条的最低可能值Lowest possible value for the secondary progress
intPROGRESS_START进度条起始值Starting value for the (primary) progress
intPROGRESS_VISIBILITY_OFF进度条不可见Flag for setting the progress bar's visibility to GONE
intPROGRESS_VISIBILITY_ON进度条可见Flag for setting the progress bar's visibility to VISIBLE
Public Constructors
 Window(Context context)构造方法
Public Methods
abstract voidaddContentView(View view, ViewGroup.LayoutParams params)
加Variation on   setContentView(View, android.view.ViewGroup.LayoutParams)  to add an additional content view to the screen.为window添加view,并且指定布局
void

addFlags(int flags)

为window添加特定的特征。

Convenience function to set the flag bits as specified in flags, as per   setFlags(int, int).
void

clearFlags(int flags)

清除window的某一特征

Convenience function to clear the flag bits as specified in flags, as per   setFlags(int, int).
abstract voidcloseAllPanels()关闭所有嵌入的面板
abstract voidclosePanel(int featureId)关闭某一个指定的嵌入面板
View

findViewById(int id)

通过id获取view。通过onCreate方法中处理的xml文件中标识View的 id,获取view。

Finds a view that was identified by the id attribute from the XML that was processed in   onCreate(Bundle).
final WindowManager.LayoutParams

getAttributes()

获取当前窗口与这个面板相关的属性(布局信息)。

Retrieve the current window attributes associated with this panel.
final Window.Callback

getCallback()

获取这个窗口的回调接口。

Return the current Callback interface for this window.
final Window

getContainer()

获取这个窗口的容器(还是一个窗口)

Return the container for this Window.
final Context

getContext()

获取这个正在运行的窗口的上下文信息,从而可以从这些信息中获取到资源和其他的信息。

Return the Context this window policy is running in, for retrieving resources and other information.
abstract View

getCurrentFocus()

获取当前窗口中当前得到焦点的view。如果没有任何view得到焦点,则返回空。

Return the view in this Window that currently has focus, or null if there are none.
abstract View

getDecorView()

获得修饰view。获得顶层窗口的修饰view(包括标准窗口框架结构,修饰和窗口中的内容)。这个修饰view可以被当作一个window加入到window manager中。

Retrieve the top-level window decor view (containing the standard window frame/decorations and the client's content inside of that), which can be added as a window to the window manager.
abstract LayoutInflater

getLayoutInflater()

获得LayoutInflater实例。这个实例是从窗口从自己的上下文信息中得到的。

Quick access to the   LayoutInflater  instance that this Window retrieved from its Context.
abstract intgetVolumeControlStream()获得音量控制流
WindowManager

getWindowManager()

获得这个window的窗口管理器window manager。window manager 允许这个window显示它的windows。

Return the window manager allowing this Window to display its own windows.
final TypedArray

getWindowStyle()

获得窗口主题的窗口属性。

Return the   Window  attributes from this window's theme.
final booleanhasChildren()有子孩子
boolean

hasFeature(int feature)

查询是否有某一个特定的特征

Query for the availability of a certain feature.
void

injectInputEvent(InputEvent event)

为窗口注册一个本地输入事件

Inject an event to window locally.
abstract void

invalidatePanelMenu(int featureId)无效的面板菜单(特征 id)

final booleanisActive()是否激活
abstract boolean

isFloating()

是否是悬浮状态

Return whether this window is being displayed with a floating style (based on the   windowIsFloatingattribute in the style/theme).
abstract boolean

isShortcutKey(int keyCode, KeyEvent event)

是否是这个窗口的快捷键(键码,键盘事件)

Is a keypress one of the defined shortcut keys for this window.
final voidmakeActive()让这个窗口处于激活状态
abstract void

onConfigurationChanged(Configuration newConfig)

但窗口的配置信息改变时(新的配置信息)

Should be called when the configuration is changed.
abstract voidopenPanel(int featureId, KeyEvent event)打开面板(特征Id,键盘事件)
abstract View

peekDecorView()

获得当前窗口的修饰view:decor view.前提是这个修饰view已经被创建,否则会返回空

Retrieve the current decor view, but only if it has already been created; otherwise returns null.
abstract booleanperformContextMenuIdentifierAction(int id, int flags)执行上下为文菜单某一标识的动作(id,标识)
abstract booleanperformPanelIdentifierAction(int featureId, int id, int flags)执行面板标识动作(特征Id,id,标识)
abstract booleanperformPanelShortcut(int featureId, int keyCode, KeyEvent event, int flags)执行面板快捷键(特征Id,键码,键盘事件)
boolean

requestFeature(int featureId)

请求某一扩展的屏幕特征有效(特征Id)

Enable extended screen features.
abstract voidrestoreHierarchyState(Bundle savedInstanceState)恢复等级状态(保存的实例状态)
abstract BundlesaveHierarchyState()保存等级状态
void

setAttributes(WindowManager.LayoutParams a)

设置自定义窗口属性(管理布局参数)

Specify custom window attributes.
abstract void

setBackgroundDrawable(Drawable drawable)

设置窗口背景图片(图片)

Change the background of this window to a custom Drawable.
void

setBackgroundDrawableResource(int resid)

设置窗口背景图像资源(资源Id)

Change the background of this window to a Drawable resource.
void

setCallback(Window.Callback callback)

设置这个窗口的回调接口,用于中断按键事件和其他窗口中的动态操作

Set the Callback interface for this window, used to intercept key events and other dynamic operations in the window.
abstract voidsetChildDrawable(int featureId, Drawable drawable)设置子图片(特征Id,图片)
abstract voidsetChildInt(int featureId, int value)设置子Id(特征Id,值)
void

setContainer(Window container)

为这个窗口设置容器(容器[本质还是个窗口])

Set the container for this window.
abstract void

setContentView(View view)

设置内容view(view)。这是相对于setContetView(View,LayoutParams)的一个更直接的方法。

Convenience for   setContentView(View, android.view.ViewGroup.LayoutParams)  set the screen content to an explicit view.
abstract void

setContentView(int layoutResID)

设置内容view(资源)

Convenience for   setContentView(View, android.view.ViewGroup.LayoutParams)  to set the screen content from a layout resource.
abstract void

setContentView(View view, ViewGroup.LayoutParams params)

设置内容view(view,LayoutParams)

Set the screen content to an explicit view.
void

setDimAmount(float amount)

设置窗口背后的模糊度

Set the amount of dim behind the window when using   FLAG_DIM_BEHIND.
abstract voidsetFeatureDrawable(int featureId, Drawable drawable)
设置特征图片(特征Id,图片)
Set an explicit Drawable value for feature of this window.
abstract voidsetFeatureDrawableAlpha(int featureId, int alpha)
设置特征图片透明度(特征Id,透明度)
Set a custom alpha value for the given drawale feature, controlling how much the background is visible through it.
abstract void

setFeatureDrawableResource(int featureId, int resId)

设置特征图片资源(特征id,资源)

Set the value for a drawable feature of this window, from a resource identifier.
abstract void

setFeatureDrawableUri(int featureId, Uri uri)

设置特征图片Uril(特征Id,uri)

Set the value for a drawable feature of this window, from a URI.
abstract void

setFeatureInt(int featureId, int value)

设置特征(特征Id,值)

Set the integer value for a feature.
void

setFlags(int flags, int mask)

设置window的标记,作为一个WindowManager.LayoutParams的标记。

Set the flags of the window, as per the   WindowManager.LayoutParams  flags.
void

setFormat(int format)

设置格式(像素格式)

Set the format of window, as per the PixelFormat types.
void

setGravity(int gravity)

设置权重(权重)

Set the gravity of the window, as per the Gravity constants.
void

setIcon(int resId)

为窗口设置设置图标(资源)

Set the primary icon for this window.
void

setLayout(int width, int height)

设置布局(宽度,高度)

Set the width and height layout parameters of the window.
void

setLocalFocus(boolean hasFocus, boolean inTouchMode)

设置本地焦点(是否具有焦点,是否是触屏模式)

Set focus locally.
void

setLogo(int resId)

设置Logo(资源)

Set the logo for this window.
void

setSoftInputMode(int mode)

设置软输入模式(模式)

Specify an explicit soft input mode to use for the window, as per WindowManager.LayoutParams.softInputMode.
abstract void

setTitle(CharSequence title)设置标题(标题)

abstract voidsetTitleColor(int textColor)设置标题颜色(颜色)
void

setType(int type)

设置窗口类型(类型),正如每个窗口布局的类型

Set the type of the window, as per the WindowManager.LayoutParams types.

void

setUiOptions(int uiOptions)

设置额外的UI操作(UI操作)

Set extra options that will influence the UI for this window.
void

setUiOptions(int uiOptions, int mask)

设置额外的UI操作选项(操作,动作掩码)

Set extra options that will influence the UI for this window.
abstract voidsetVolumeControlStream(int streamType)设置音量控制流(流类型)
void

setWindowAnimations(int resId)

设置窗口动画(动画资源)

Specify custom animations to use for the window, as per   WindowManager.LayoutParams.windowAnimations.
void

setWindowManager(WindowManager wm, IBinder appToken, String appName, boolean hardwareAccelerated)

设置窗口所用的窗口管理器,如用来显示plane。

Set the window manager for use by this Window to, for example, display panels.
void

setWindowManager(WindowManager wm, IBinder appToken, String appName)

设置窗口所用的窗口管理器,如用来显示plane。

Set the window manager for use by this Window to, for example, display panels.
abstract boolean

superDispatchGenericMotionEvent(MotionEvent event)

派遣鼠标事件(鼠标事件)

被自定义的window使用,如diaglog。用于将一般的鼠标事件向下传递到view层级中。

Used by custom windows, such as Dialog, to pass the generic motion event further down the view hierarchy.
abstract boolean

superDispatchKeyEvent(KeyEvent event)

派遣键盘事件(键盘事件)

被自定义的window使用,如diaglog。用于将一般的按键事件向下传递到view层级中。

Used by custom windows, such as Dialog, to pass the key press event further down the view hierarchy.
abstract boolean

superDispatchKeyShortcutEvent(KeyEvent event)

派遣快捷键事件(键盘事件)

被自定义的window使用,如dialog。用于将一般的键盘事件向下传递到view层级中。

Used by custom windows, such as Dialog, to pass the key shortcut press event further down the view hierarchy.
abstract boolean

superDispatchTouchEvent(MotionEvent event)

派遣触摸事件(鼠标事件)

被自定义的window使用,如dialog。用于将一般的触屏事件向下传递到view层级中。

Used by custom windows, such as Dialog, to pass the touch screen event further down the view hierarchy.
abstract boolean

superDispatchTrackballEvent(MotionEvent event)

派遣轨迹事件(鼠标事件)

被自定义的window使用,如dialog,用于将轨迹事件向下传递到view的层级中。

Used by custom windows, such as Dialog, to pass the trackball event further down the view hierarchy.
abstract void

takeInputQueue(InputQueue.Callback callback)

取得输入的队列(输入回调接口)  获得输入队列的所有权

Take ownership of this window's InputQueue.
abstract void

takeKeyEvents(boolean get)

取得键盘事件(是否获得)  请求获得键盘事件到这个activity。

Request that key events come to this activity.
abstract void

takeSurface(SurfaceHolder.Callback2 callback)

取得该window的surface的拥有权控制权。(SurfaceHolder.CallBack2接口)

Take ownership of this window's surface.
abstract voidtogglePanel(int featureId, KeyEvent event)    切换面板(特征Id,键盘事件)
Protected Methods
final intgetFeatures()
获取启用的特征
Return the feature bits that are enabled.
final int

getForcedWindowFlags()

获取被客户明确设置的window flag,因此将不会被getDecorView修改。

Return the window flags that have been explicitly set by the client, so will not be modified by   getDecorView().
final int

getLocalFeatures()

获取被这个窗口实现的特征

Return the feature bits that are being implemented by this Window.
final boolean

hasSoftInputMode()

是否有软输入模式

Has the app specified their own soft input mode?
abstract voidonActive()是否激活
void

setDefaultWindowFormat(int format)

设置默认的窗口模式(模式)

Set the default format of window, as per the PixelFormat types.

转载于:https://www.cnblogs.com/muyable/p/3763821.html

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值