java.lang.Object | |
↳ | android.view.Window |
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.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Window.Callback | API from a Window back to its caller. |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | DEFAULT_FEATURES | The default features enabled | |||||||||
int | FEATURE_ACTION_BAR | Flag for enabling the Action Bar. | |||||||||
int | FEATURE_ACTION_BAR_OVERLAY | Flag for requesting an Action Bar that overlays window content. | |||||||||
int | FEATURE_ACTION_MODE_OVERLAY | Flag for specifying the behavior of action modes when an Action Bar is not present. | |||||||||
int | FEATURE_CONTEXT_MENU | Flag for the context menu. | |||||||||
int | FEATURE_CUSTOM_TITLE | Flag for custom title. | |||||||||
int | FEATURE_INDETERMINATE_PROGRESS | Flag for indeterminate progress | |||||||||
int | FEATURE_LEFT_ICON | Flag for having an icon on the left side of the title bar | |||||||||
int | FEATURE_NO_TITLE | Flag for the "no title" feature, turning off the title at the top of the screen. | |||||||||
int | FEATURE_OPTIONS_PANEL | Flag for the "options panel" feature. | |||||||||
int | FEATURE_PROGRESS | Flag for the progress indicator feature | |||||||||
int | FEATURE_RIGHT_ICON | Flag for having an icon on the right side of the title bar | |||||||||
int | ID_ANDROID_CONTENT | The ID that the main layout in the XML layout file should have. | |||||||||
int | PROGRESS_END | Ending value for the (primary) progress | |||||||||
int | PROGRESS_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 | |||||||||
int | PROGRESS_SECONDARY_END | Highest possible value for the secondary progress | |||||||||
int | PROGRESS_SECONDARY_START | Lowest possible value for the secondary progress | |||||||||
int | PROGRESS_START | Starting value for the (primary) progress | |||||||||
int | PROGRESS_VISIBILITY_OFF | Flag for setting the progress bar's visibility to GONE | |||||||||
int | PROGRESS_VISIBILITY_ON | Flag for setting the progress bar's visibility to VISIBLE |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Variation on
setContentView(View, android.view.ViewGroup.LayoutParams)
to add an additional content view to the screen. | |||||||||||
Convenience function to set the flag bits as specified in flags, as
per
setFlags(int, int) . | |||||||||||
Convenience function to clear the flag bits as specified in flags, as
per
setFlags(int, int) . | |||||||||||
Finds a view that was identified by the id attribute from the XML that
was processed in
onCreate(Bundle) . | |||||||||||
Retrieve the current window attributes associated with this panel.
| |||||||||||
Return the current Callback interface for this window.
| |||||||||||
Return the container for this Window.
| |||||||||||
Return the Context this window policy is running in, for retrieving
resources and other information.
| |||||||||||
Return the view in this Window that currently has focus, or null if
there are none.
| |||||||||||
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.
| |||||||||||
Quick access to the
LayoutInflater instance that this Window
retrieved from its Context. | |||||||||||
Return the window manager allowing this Window to display its own
windows.
| |||||||||||
Return the
Window attributes from this
window's theme. | |||||||||||
Query for the availability of a certain feature.
| |||||||||||
Inject an event to window locally.
| |||||||||||
Return whether this window is being displayed with a floating style
(based on the
windowIsFloating attribute in
the style/theme). | |||||||||||
Is a keypress one of the defined shortcut keys for this window.
| |||||||||||
Should be called when the configuration is changed.
| |||||||||||
Retrieve the current decor view, but only if it has already been created;
otherwise returns null.
| |||||||||||
Enable extended screen features.
| |||||||||||
Specify custom window attributes.
| |||||||||||
Change the background of this window to a custom Drawable.
| |||||||||||
Change the background of this window to a Drawable resource.
| |||||||||||
Set the Callback interface for this window, used to intercept key
events and other dynamic operations in the window.
| |||||||||||
Set the container for this window.
| |||||||||||
Convenience for
setContentView(View, android.view.ViewGroup.LayoutParams)
set the screen content to an explicit view. | |||||||||||
Convenience for
setContentView(View, android.view.ViewGroup.LayoutParams)
to set the screen content from a layout resource. | |||||||||||
Set the screen content to an explicit view.
| |||||||||||
Set the amount of dim behind the window when using
FLAG_DIM_BEHIND . | |||||||||||
Set an explicit Drawable value for feature of this window.
| |||||||||||
Set a custom alpha value for the given drawale feature, controlling how
much the background is visible through it.
| |||||||||||
Set the value for a drawable feature of this window, from a resource
identifier.
| |||||||||||
Set the value for a drawable feature of this window, from a URI.
| |||||||||||
Set the integer value for a feature.
| |||||||||||
Set the flags of the window, as per the
WindowManager.LayoutParams
flags. | |||||||||||
Set the format of window, as per the PixelFormat types.
| |||||||||||
Set the gravity of the window, as per the Gravity constants.
| |||||||||||
Set the primary icon for this window.
| |||||||||||
Set the width and height layout parameters of the window.
| |||||||||||
Set focus locally.
| |||||||||||
Set the logo for this window.
| |||||||||||
Specify an explicit soft input mode to use for the window, as per
WindowManager.LayoutParams.softInputMode . | |||||||||||
Set the type of the window, as per the WindowManager.LayoutParams
types.
| |||||||||||
Set extra options that will influence the UI for this window.
| |||||||||||
Set extra options that will influence the UI for this window.
| |||||||||||
Specify custom animations to use for the window, as per
WindowManager.LayoutParams.windowAnimations . | |||||||||||
Set the window manager for use by this Window to, for example,
display panels.
| |||||||||||
Set the window manager for use by this Window to, for example,
display panels.
| |||||||||||
Used by custom windows, such as Dialog, to pass the generic motion event
further down the view hierarchy.
| |||||||||||
Used by custom windows, such as Dialog, to pass the key press event
further down the view hierarchy.
| |||||||||||
Used by custom windows, such as Dialog, to pass the key shortcut press event
further down the view hierarchy.
| |||||||||||
Used by custom windows, such as Dialog, to pass the touch screen event
further down the view hierarchy.
| |||||||||||
Used by custom windows, such as Dialog, to pass the trackball event
further down the view hierarchy.
| |||||||||||
Take ownership of this window's InputQueue.
| |||||||||||
Request that key events come to this activity.
| |||||||||||
Take ownership of this window's surface.
| |||||||||||
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Return the feature bits that are enabled.
| |||||||||||
Return the window flags that have been explicitly set by the client,
so will not be modified by
getDecorView() . | |||||||||||
Return the feature bits that are being implemented by this Window.
| |||||||||||
Has the app specified their own soft input mode?
| |||||||||||
Set the default format of window, as per the PixelFormat types.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
The default features enabled
Flag for enabling the Action Bar. This is enabled by default for some devices. The Action Bar replaces the title bar and provides an alternate location for an on-screen menu button on some devices.
Flag for requesting an Action Bar that overlays window content.
Normally an Action Bar will sit in the space above window content, but if this
feature is requested along with FEATURE_ACTION_BAR
it will be layered over
the window content itself. This is useful if you would like your app to have more control
over how the Action Bar is displayed, such as letting application content scroll beneath
an Action Bar with a transparent background or otherwise displaying a transparent/translucent
Action Bar over application content.
This mode is especially useful with View.SYSTEM_UI_FLAG_FULLSCREEN
, which allows you to seamlessly hide the
action bar in conjunction with other screen decorations.
As of JELLY_BEAN
, when an
ActionBar is in this mode it will adjust the insets provided to
View.fitSystemWindows(Rect)
to include the content covered by the action bar, so you can do layout within
that space.
Flag for specifying the behavior of action modes when an Action Bar is not present. If overlay is enabled, the action mode UI will be allowed to cover existing window content.
Flag for the context menu. This is enabled by default.
Flag for custom title. You cannot combine this feature with other title features.
Flag for indeterminate progress
Flag for having an icon on the left side of the title bar
Flag for the "no title" feature, turning off the title at the top of the screen.
Flag for the "options panel" feature. This is enabled by default.
Flag for the progress indicator feature
Flag for having an icon on the right side of the title bar
The ID that the main layout in the XML layout file should have.
Ending value for the (primary) progress
Flag for setting the progress bar's indeterminate mode off
Flag for setting the progress bar's indeterminate mode on
Highest possible value for the secondary progress
Lowest possible value for the secondary progress
Starting value for the (primary) progress
Flag for setting the progress bar's visibility to GONE
Flag for setting the progress bar's visibility to VISIBLE
Variation on
setContentView(View, android.view.ViewGroup.LayoutParams)
to add an additional content view to the screen. Added after any existing
ones in the screen -- existing views are NOT removed.
view | The desired content to display. |
---|---|
params | Layout parameters for the view. |
Convenience function to set the flag bits as specified in flags, as
per setFlags(int, int)
.
flags | The flag bits to be set. |
---|
Convenience function to clear the flag bits as specified in flags, as
per setFlags(int, int)
.
flags | The flag bits to be cleared. |
---|
Finds a view that was identified by the id attribute from the XML that
was processed in onCreate(Bundle)
. This will
implicitly call getDecorView()
for you, with all of the
associated side-effects.
Retrieve the current window attributes associated with this panel.
Return the current Callback interface for this window.
Return the container for this Window.
Return the Context this window policy is running in, for retrieving resources and other information.
Return the view in this Window that currently has focus, or null if there are none. Note that this does not look in any containing Window.
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.
Note that calling this function for the first time "locks in"
various window characteristics as described in
setContentView(View, android.view.ViewGroup.LayoutParams)
.
Quick access to the LayoutInflater
instance that this Window
retrieved from its Context.
Return the window manager allowing this Window to display its own windows.
Return the Window
attributes from this
window's theme.
Query for the availability of a certain feature.
feature | The feature ID to check |
---|
Inject an event to window locally.
event | A key or touch event to inject to this window. |
---|
Return whether this window is being displayed with a floating style
(based on the windowIsFloating
attribute in
the style/theme).
Should be called when the configuration is changed.
newConfig | The new configuration. |
---|
Retrieve the current decor view, but only if it has already been created; otherwise returns null.
Enable extended screen features. This must be called before
setContentView(). May be called as many times as desired as long as it
is before setContentView(). If not called, no extended features
will be available. You can not turn off a feature once it is requested.
You canot use other title features with FEATURE_CUSTOM_TITLE
.
featureId | The desired features, defined as constants by Window. |
---|
Specify custom window attributes. PLEASE NOTE: the
layout params you give here should generally be from values previously
retrieved with getAttributes()
; you probably do not want to
blindly create and apply your own, since this will blow away any values
set by the framework that you are not interested in.
a | The new window attributes, which will completely override any current values. |
---|
Change the background of this window to a custom Drawable. Setting the background to null will make the window be opaque. To make the window transparent, you can use an empty drawable (for instance a ColorDrawable with the color 0 or the system drawable android:drawable/empty.)
drawable | The new Drawable to use for this window's background. |
---|
Change the background of this window to a Drawable resource. Setting the background to null will make the window be opaque. To make the window transparent, you can use an empty drawable (for instance a ColorDrawable with the color 0 or the system drawable android:drawable/empty.)
resid | The resource identifier of a drawable resource which will be installed as the new background. |
---|
Set the Callback interface for this window, used to intercept key events and other dynamic operations in the window.
callback | The desired Callback interface. |
---|
Set the container for this window. If not set, the DecorWindow operates as a top-level window; otherwise, it negotiates with the container to display itself appropriately.
container | The desired containing Window. |
---|
Convenience for
setContentView(View, android.view.ViewGroup.LayoutParams)
set the screen content to an explicit view. This view is placed
directly into the screen's view hierarchy. It can itself be a complex
view hierarhcy.
view | The desired content to display. |
---|
Convenience for
setContentView(View, android.view.ViewGroup.LayoutParams)
to set the screen content from a layout resource. The resource will be
inflated, adding all top-level views to the screen.
layoutResID | Resource ID to be inflated. |
---|
Set the screen content to an explicit view. This view is placed directly into the screen's view hierarchy. It can itself be a complex view hierarchy.
Note that calling this function "locks in" various characteristics
of the window that can not, from this point forward, be changed: the
features that have been requested with requestFeature(int)
,
and certain window flags as described in setFlags(int, int)
.
view | The desired content to display. |
---|---|
params | Layout parameters for the view. |
Set the amount of dim behind the window when using
FLAG_DIM_BEHIND
. This overrides
the default dim amount of that is selected by the Window based on
its theme.
amount | The new dim amount, from 0 for no dim to 1 for full dim. |
---|
Set an explicit Drawable value for feature of this window. You must have called requestFeature(featureId) before calling this function.
featureId | The desired drawable feature to change. Features are constants defined by Window. |
---|---|
drawable | A Drawable object to display. |
Set a custom alpha value for the given drawale feature, controlling how much the background is visible through it.
featureId | The desired drawable feature to change. Features are constants defined by Window. |
---|---|
alpha | The alpha amount, 0 is completely transparent and 255 is completely opaque. |
Set the value for a drawable feature of this window, from a resource identifier. You must have called requestFeauture(featureId) before calling this function.
featureId | The desired drawable feature to change, defined as a constant by Window. |
---|---|
resId | Resource identifier of the desired image. |
Set the value for a drawable feature of this window, from a URI. You must have called requestFeature(featureId) before calling this function.
The only URI currently supported is "content:", specifying an image in a content provider.
featureId | The desired drawable feature to change. Features are constants defined by Window. |
---|---|
uri | The desired URI. |
Set the integer value for a feature. The range of the value depends on the feature being set. For FEATURE_PROGRESSS, it should go from 0 to 10000. At 10000 the progress is complete and the indicator hidden.
featureId | The desired feature to change. Features are constants defined by Window. |
---|---|
value | The value for the feature. The interpretation of this value is feature-specific. |
Set the flags of the window, as per the
WindowManager.LayoutParams
flags.
Note that some flags must be set before the window decoration is
created (by the first call to
setContentView(View, android.view.ViewGroup.LayoutParams)
or
getDecorView()
:
FLAG_LAYOUT_IN_SCREEN
and
FLAG_LAYOUT_INSET_DECOR
. These
will be set for you based on the windowIsFloating
attribute.
flags | The new window flags (see WindowManager.LayoutParams). |
---|---|
mask | Which of the window flag bits to modify. |
Set the format of window, as per the PixelFormat types. This overrides the default format that is selected by the Window based on its window decorations.
format | The new window format (see PixelFormat). Use PixelFormat.UNKNOWN to allow the Window to select the format. |
---|
Set the gravity of the window, as per the Gravity constants. This controls how the window manager is positioned in the overall window; it is only useful when using WRAP_CONTENT for the layout width or height.
gravity | The desired gravity constant. |
---|
Set the primary icon for this window.
resId | resource ID of a drawable to set |
---|
Set the width and height layout parameters of the window. The default for both of these is MATCH_PARENT; you can change them to WRAP_CONTENT or an absolute value to make a window that is not full-screen.
width | The desired layout width of the window. |
---|---|
height | The desired layout height of the window. |
Set focus locally. The window should have the
FLAG_LOCAL_FOCUS_MODE
flag set already.
hasFocus | Whether this window has focus or not. |
---|---|
inTouchMode | Whether this window is in touch mode or not. |
Set the logo for this window. A logo is often shown in place of an
icon
but is generally wider and communicates window title information
as well.
resId | resource ID of a drawable to set |
---|
Specify an explicit soft input mode to use for the window, as per
WindowManager.LayoutParams.softInputMode
. Providing anything besides
"unspecified" here will override the input mode the window would
normally retrieve from its theme.
Set the type of the window, as per the WindowManager.LayoutParams types.
type | The new window type (see WindowManager.LayoutParams). |
---|
Set extra options that will influence the UI for this window.
uiOptions | Flags specifying extra options for this window. |
---|
Set extra options that will influence the UI for this window. Only the bits filtered by mask will be modified.
uiOptions | Flags specifying extra options for this window. |
---|---|
mask | Flags specifying which options should be modified. Others will remain unchanged. |
Specify custom animations to use for the window, as per
WindowManager.LayoutParams.windowAnimations
. Providing anything besides
0 here will override the animations the window would
normally retrieve from its theme.
Set the window manager for use by this Window to, for example, display panels. This is not used for displaying the Window itself -- that must be done by the client.
wm | The window manager for adding new windows. |
---|
Set the window manager for use by this Window to, for example, display panels. This is not used for displaying the Window itself -- that must be done by the client.
wm | The window manager for adding new windows. |
---|
Used by custom windows, such as Dialog, to pass the generic motion event further down the view hierarchy. Application developers should not need to implement or call this.
Used by custom windows, such as Dialog, to pass the key press event further down the view hierarchy. Application developers should not need to implement or call this.
Used by custom windows, such as Dialog, to pass the key shortcut press event further down the view hierarchy. Application developers should not need to implement or call this.
Used by custom windows, such as Dialog, to pass the touch screen event further down the view hierarchy. Application developers should not need to implement or call this.
Used by custom windows, such as Dialog, to pass the trackball event further down the view hierarchy. Application developers should not need to implement or call this.
Take ownership of this window's InputQueue. The window will no longer read and dispatch input events from the queue; it is your responsibility to do so.
Request that key events come to this activity. Use this if your activity has no views with focus, but the activity still wants a chance to process key events.
Take ownership of this window's surface. The window's view hierarchy will no longer draw into the surface, though it will otherwise continue to operate (such as for receiving input events). The given SurfaceHolder callback will be used to tell you about state changes to the surface.
Return the feature bits that are enabled. This is the set of features that were given to requestFeature(), and are being handled by this Window itself or its container. That is, it is the set of requested features that you can actually use.
To do: add a public version of this API that allows you to check for features by their feature ID.
Return the window flags that have been explicitly set by the client,
so will not be modified by getDecorView()
.
Return the feature bits that are being implemented by this Window. This is the set of features that were given to requestFeature(), and are being handled by only this Window itself, not by its containers.
Has the app specified their own soft input mode?
Set the default format of window, as per the PixelFormat types. This is the format that will be used unless the client specifies in explicit format with setFormat();
format | The new window format (see PixelFormat). |
---|