public abstract class Window extends Object
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.
Modifier and Type | Class and Description |
---|---|
static interface |
Window.Callback
API from a Window back to its caller.
|
Modifier and Type | Field and Description |
---|---|
protected static int |
DEFAULT_FEATURES
The default features enabled
|
static int |
FEATURE_ACTION_BAR
Flag for enabling the Action Bar.
|
static int |
FEATURE_ACTION_BAR_OVERLAY
Flag for requesting an Action Bar that overlays window content.
|
static int |
FEATURE_ACTION_MODE_OVERLAY
Flag for specifying the behavior of action modes when an Action Bar is not present.
|
static int |
FEATURE_CONTEXT_MENU
Flag for the context menu.
|
static int |
FEATURE_CUSTOM_TITLE
Flag for custom title.
|
static int |
FEATURE_INDETERMINATE_PROGRESS
Flag for indeterminate progress
|
static int |
FEATURE_LEFT_ICON
Flag for having an icon on the left side of the title bar
|
static int |
FEATURE_MAX
Max value used as a feature ID
|
static int |
FEATURE_NO_TITLE
Flag for the "no title" feature, turning off the title at the top
of the screen.
|
static int |
FEATURE_OPTIONS_PANEL
Flag for the "options panel" feature.
|
static int |
FEATURE_PROGRESS
Flag for the progress indicator feature
|
static int |
FEATURE_RIGHT_ICON
Flag for having an icon on the right side of the title bar
|
static int |
ID_ANDROID_CONTENT
The ID that the main layout in the XML layout file should have.
|
static int |
PROGRESS_END
Ending value for the (primary) progress
|
static int |
PROGRESS_INDETERMINATE_OFF
Flag for setting the progress bar's indeterminate mode off
|
static int |
PROGRESS_INDETERMINATE_ON
Flag for setting the progress bar's indeterminate mode on
|
static int |
PROGRESS_SECONDARY_END
Highest possible value for the secondary progress
|
static int |
PROGRESS_SECONDARY_START
Lowest possible value for the secondary progress
|
static int |
PROGRESS_START
Starting value for the (primary) progress
|
static int |
PROGRESS_VISIBILITY_OFF
Flag for setting the progress bar's visibility to GONE
|
static int |
PROGRESS_VISIBILITY_ON
Flag for setting the progress bar's visibility to VISIBLE
|
Modifier and Type | Method and Description |
---|---|
abstract void |
addContentView(View view,
ViewGroup.LayoutParams params)
Variation on
setContentView(View, android.view.ViewGroup.LayoutParams)
to add an additional content view to the screen. |
void |
addFlags(int flags)
Convenience function to set the flag bits as specified in flags, as
per
setFlags(int, int) . |
abstract void |
alwaysReadCloseOnTouchAttr() |
void |
clearFlags(int flags)
Convenience function to clear the flag bits as specified in flags, as
per
setFlags(int, int) . |
abstract void |
closeAllPanels() |
abstract void |
closePanel(int featureId) |
void |
destroy() |
View |
findViewById(int id)
Finds a view that was identified by the id attribute from the XML that
was processed in
Activity.onCreate(android.os.Bundle) . |
WindowManager.LayoutParams |
getAttributes()
Retrieve the current window attributes associated with this panel.
|
Window.Callback |
getCallback()
Return the current Callback interface for this window.
|
Window |
getContainer()
Return the container for this Window.
|
Context |
getContext()
Return the Context this window policy is running in, for retrieving
resources and other information.
|
abstract View |
getCurrentFocus()
Return the view in this Window that currently has focus, or null if
there are none.
|
abstract View |
getDecorView()
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.
|
protected int |
getFeatures()
Return the feature bits that are enabled.
|
protected int |
getForcedWindowFlags()
Return the window flags that have been explicitly set by the client,
so will not be modified by
getDecorView() . |
abstract LayoutInflater |
getLayoutInflater()
Quick access to the
LayoutInflater instance that this Window
retrieved from its Context. |
protected int |
getLocalFeatures()
Return the feature bits that are being implemented by this Window.
|
abstract int |
getVolumeControlStream() |
WindowManager |
getWindowManager()
Return the window manager allowing this Window to display its own
windows.
|
TypedArray |
getWindowStyle()
Return the
android.R.styleable#Window attributes from this
window's theme. |
boolean |
hasChildren() |
boolean |
hasFeature(int feature)
Query for the availability of a certain feature.
|
protected boolean |
hasSoftInputMode()
Has the app specified their own soft input mode?
|
protected boolean |
haveDimAmount() |
abstract void |
invalidatePanelMenu(int featureId) |
boolean |
isActive() |
boolean |
isDestroyed() |
abstract boolean |
isFloating()
Return whether this window is being displayed with a floating style
(based on the
android.R.attr#windowIsFloating attribute in
the style/theme). |
abstract boolean |
isShortcutKey(int keyCode,
KeyEvent event)
Is a keypress one of the defined shortcut keys for this window.
|
void |
makeActive() |
protected abstract void |
onActive() |
abstract void |
onConfigurationChanged(Configuration newConfig)
Should be called when the configuration is changed.
|
abstract void |
openPanel(int featureId,
KeyEvent event) |
abstract View |
peekDecorView()
Retrieve the current decor view, but only if it has already been created;
otherwise returns null.
|
abstract boolean |
performContextMenuIdentifierAction(int id,
int flags) |
abstract boolean |
performPanelIdentifierAction(int featureId,
int id,
int flags) |
abstract boolean |
performPanelShortcut(int featureId,
int keyCode,
KeyEvent event,
int flags) |
protected void |
removeFeature(int featureId) |
boolean |
requestFeature(int featureId)
Enable extended screen features.
|
abstract void |
restoreHierarchyState(Bundle savedInstanceState) |
abstract Bundle |
saveHierarchyState() |
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)
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 void |
setChildDrawable(int featureId,
Drawable drawable) |
abstract void |
setChildInt(int featureId,
int value) |
void |
setCloseOnTouchOutside(boolean close) |
void |
setCloseOnTouchOutsideIfNotSet(boolean close) |
void |
setContainer(Window container)
Set the container for this window.
|
abstract void |
setContentView(int layoutResID)
Convenience for
setContentView(View, android.view.ViewGroup.LayoutParams)
to set the screen content from a layout resource. |
abstract void |
setContentView(View view)
Convenience for
setContentView(View, android.view.ViewGroup.LayoutParams)
set the screen content to an explicit view. |
abstract void |
setContentView(View view,
ViewGroup.LayoutParams params)
Set the screen content to an explicit view.
|
protected void |
setDefaultWindowFormat(int format)
Set the default format of window, as per the PixelFormat types.
|
void |
setDimAmount(float amount)
Set the amount of dim behind the window when using
WindowManager.LayoutParams.FLAG_DIM_BEHIND . |
abstract void |
setFeatureDrawable(int featureId,
Drawable drawable)
Set an explicit Drawable value for feature of this window.
|
abstract void |
setFeatureDrawableAlpha(int featureId,
int alpha)
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)
Set the value for a drawable feature of this window, from a resource
identifier.
|
abstract void |
setFeatureDrawableUri(int featureId,
Uri uri)
Set the value for a drawable feature of this window, from a URI.
|
abstract void |
setFeatureInt(int featureId,
int value)
Set the integer value for a feature.
|
void |
setFlags(int flags,
int mask)
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 |
setLayout(int width,
int height)
Set the width and height layout parameters of the 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 void |
setTitleColor(int textColor) |
void |
setType(int type)
Set the type of the window, as per the WindowManager.LayoutParams
types.
|
void |
setUiOptions(int uiOptions)
Set extra options that will influence the UI for this window.
|
void |
setUiOptions(int uiOptions,
int mask)
Set extra options that will influence the UI for this window.
|
abstract void |
setVolumeControlStream(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)
Set the window manager for use by this Window to, for example,
display panels.
|
void |
setWindowManager(WindowManager wm,
IBinder appToken,
String appName,
boolean hardwareAccelerated)
Set the window manager for use by this Window to, for example,
display panels.
|
boolean |
shouldCloseOnTouch(Context context,
MotionEvent event) |
abstract boolean |
superDispatchGenericMotionEvent(MotionEvent event)
Used by custom windows, such as Dialog, to pass the generic motion event
further down the view hierarchy.
|
abstract boolean |
superDispatchKeyEvent(KeyEvent event)
Used by custom windows, such as Dialog, to pass the key press event
further down the view hierarchy.
|
abstract boolean |
superDispatchKeyShortcutEvent(KeyEvent event)
Used by custom windows, such as Dialog, to pass the key shortcut press event
further down the view hierarchy.
|
abstract boolean |
superDispatchTouchEvent(MotionEvent event)
Used by custom windows, such as Dialog, to pass the touch screen event
further down the view hierarchy.
|
abstract boolean |
superDispatchTrackballEvent(MotionEvent event)
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)
Request that key events come to this activity.
|
abstract void |
takeSurface(SurfaceHolder.Callback2 callback)
Take ownership of this window's surface.
|
abstract void |
togglePanel(int featureId,
KeyEvent event) |
public static final int FEATURE_OPTIONS_PANEL
public static final int FEATURE_NO_TITLE
public static final int FEATURE_PROGRESS
public static final int FEATURE_LEFT_ICON
public static final int FEATURE_RIGHT_ICON
public static final int FEATURE_INDETERMINATE_PROGRESS
public static final int FEATURE_CONTEXT_MENU
public static final int FEATURE_CUSTOM_TITLE
public static final int FEATURE_ACTION_BAR
public static final int FEATURE_ACTION_BAR_OVERLAY
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 Build.VERSION_CODES.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.
public static final int FEATURE_ACTION_MODE_OVERLAY
public static final int FEATURE_MAX
public static final int PROGRESS_VISIBILITY_ON
public static final int PROGRESS_VISIBILITY_OFF
public static final int PROGRESS_INDETERMINATE_ON
public static final int PROGRESS_INDETERMINATE_OFF
public static final int PROGRESS_START
public static final int PROGRESS_END
public static final int PROGRESS_SECONDARY_START
public static final int PROGRESS_SECONDARY_END
protected static final int DEFAULT_FEATURES
public static final int ID_ANDROID_CONTENT
public Window(Context context)
public final Context getContext()
public final TypedArray getWindowStyle()
android.R.styleable#Window
attributes from this
window's theme.public void setContainer(Window container)
container
- The desired containing Window.public final Window getContainer()
public final boolean hasChildren()
public final void destroy()
public final boolean isDestroyed()
public void setWindowManager(WindowManager wm, IBinder appToken, String appName)
wm
- The window manager for adding new windows.public void setWindowManager(WindowManager wm, IBinder appToken, String appName, boolean hardwareAccelerated)
wm
- The window manager for adding new windows.public WindowManager getWindowManager()
public void setCallback(Window.Callback callback)
callback
- The desired Callback interface.public final Window.Callback getCallback()
public abstract void takeSurface(SurfaceHolder.Callback2 callback)
public abstract void takeInputQueue(InputQueue.Callback callback)
public abstract boolean isFloating()
android.R.attr#windowIsFloating
attribute in
the style/theme).public void setLayout(int width, int height)
width
- The desired layout width of the window.height
- The desired layout height of the window.ViewGroup.LayoutParams.height
,
ViewGroup.LayoutParams.width
public void setGravity(int gravity)
gravity
- The desired gravity constant.Gravity
,
setLayout(int, int)
public void setType(int type)
type
- The new window type (see WindowManager.LayoutParams).public void setFormat(int format)
format
- The new window format (see PixelFormat). Use
PixelFormat.UNKNOWN to allow the Window to select
the format.PixelFormat
public void setWindowAnimations(int resId)
WindowManager.LayoutParams.windowAnimations
. Providing anything besides
0 here will override the animations the window would
normally retrieve from its theme.public void setSoftInputMode(int mode)
WindowManager.LayoutParams.softInputMode
. Providing anything besides
"unspecified" here will override the input mode the window would
normally retrieve from its theme.public void addFlags(int flags)
setFlags(int, int)
.flags
- The flag bits to be set.setFlags(int, int)
,
clearFlags(int)
public void clearFlags(int flags)
setFlags(int, int)
.flags
- The flag bits to be cleared.setFlags(int, int)
,
addFlags(int)
public void setFlags(int flags, int mask)
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()
:
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
and
WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
. These
will be set for you based on the android.R.attr#windowIsFloating
attribute.
flags
- The new window flags (see WindowManager.LayoutParams).mask
- Which of the window flag bits to modify.addFlags(int)
,
clearFlags(int)
public void setDimAmount(float amount)
WindowManager.LayoutParams.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.public void setAttributes(WindowManager.LayoutParams a)
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.public final WindowManager.LayoutParams getAttributes()
protected final int getForcedWindowFlags()
getDecorView()
.protected final boolean hasSoftInputMode()
public void setCloseOnTouchOutside(boolean close)
public void setCloseOnTouchOutsideIfNotSet(boolean close)
public abstract void alwaysReadCloseOnTouchAttr()
public boolean shouldCloseOnTouch(Context context, MotionEvent event)
public boolean requestFeature(int featureId)
FEATURE_CUSTOM_TITLE
.featureId
- The desired features, defined as constants by Window.protected void removeFeature(int featureId)
public final void makeActive()
public final boolean isActive()
public View findViewById(int id)
Activity.onCreate(android.os.Bundle)
. This will
implicitly call getDecorView()
for you, with all of the
associated side-effects.public abstract void setContentView(int layoutResID)
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.setContentView(View, android.view.ViewGroup.LayoutParams)
public abstract void setContentView(View view)
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.setContentView(View, android.view.ViewGroup.LayoutParams)
public abstract void setContentView(View view, ViewGroup.LayoutParams params)
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.public abstract void addContentView(View view, ViewGroup.LayoutParams params)
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.public abstract View getCurrentFocus()
public abstract LayoutInflater getLayoutInflater()
LayoutInflater
instance that this Window
retrieved from its Context.public abstract void setTitle(CharSequence title)
public abstract void setTitleColor(int textColor)
public abstract void openPanel(int featureId, KeyEvent event)
public abstract void closePanel(int featureId)
public abstract void togglePanel(int featureId, KeyEvent event)
public abstract void invalidatePanelMenu(int featureId)
public abstract boolean performPanelShortcut(int featureId, int keyCode, KeyEvent event, int flags)
public abstract boolean performPanelIdentifierAction(int featureId, int id, int flags)
public abstract void closeAllPanels()
public abstract boolean performContextMenuIdentifierAction(int id, int flags)
public abstract void onConfigurationChanged(Configuration newConfig)
newConfig
- The new configuration.public void setBackgroundDrawableResource(int resid)
resid
- The resource identifier of a drawable resource which will be
installed as the new background.public abstract void setBackgroundDrawable(Drawable drawable)
drawable
- The new Drawable to use for this window's background.public abstract void setFeatureDrawableResource(int featureId, int resId)
featureId
- The desired drawable feature to change, defined as a
constant by Window.resId
- Resource identifier of the desired image.Resources.getDrawable(int)
public abstract void setFeatureDrawableUri(int featureId, Uri uri)
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.ImageView.setImageURI(android.net.Uri)
public abstract void setFeatureDrawable(int featureId, Drawable drawable)
featureId
- The desired drawable feature to change.
Features are constants defined by Window.drawable
- A Drawable object to display.public abstract void setFeatureDrawableAlpha(int featureId, int alpha)
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.public abstract void setFeatureInt(int featureId, int value)
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.public abstract void takeKeyEvents(boolean get)
public abstract boolean superDispatchKeyEvent(KeyEvent event)
public abstract boolean superDispatchKeyShortcutEvent(KeyEvent event)
public abstract boolean superDispatchTouchEvent(MotionEvent event)
public abstract boolean superDispatchTrackballEvent(MotionEvent event)
public abstract boolean superDispatchGenericMotionEvent(MotionEvent event)
public abstract View getDecorView()
Note that calling this function for the first time "locks in"
various window characteristics as described in
setContentView(View, android.view.ViewGroup.LayoutParams)
.
public abstract View peekDecorView()
getDecorView()
public abstract Bundle saveHierarchyState()
public abstract void restoreHierarchyState(Bundle savedInstanceState)
protected abstract void onActive()
protected final int getFeatures()
To do: add a public version of this API that allows you to check for features by their feature ID.
public boolean hasFeature(int feature)
feature
- The feature ID to checkprotected final int getLocalFeatures()
protected void setDefaultWindowFormat(int format)
format
- The new window format (see PixelFormat).setFormat(int)
,
PixelFormat
protected boolean haveDimAmount()
public abstract void setChildDrawable(int featureId, Drawable drawable)
public abstract void setChildInt(int featureId, int value)
public abstract boolean isShortcutKey(int keyCode, KeyEvent event)
public abstract void setVolumeControlStream(int streamType)
Activity.setVolumeControlStream(int)
public abstract int getVolumeControlStream()
Activity.getVolumeControlStream()
public void setUiOptions(int uiOptions)
uiOptions
- Flags specifying extra options for this window.public void setUiOptions(int uiOptions, int mask)
uiOptions
- Flags specifying extra options for this window.mask
- Flags specifying which options should be modified. Others will remain unchanged.