Android APIs
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.

Summary

Nested Classes
interface 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_CONTENT_TRANSITIONS Flag for requesting that window content changes should be represented with scenes and transitions.
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 FEATURE_SWIPE_TO_DISMISS Flag for requesting a decoration-free window that is dismissed by swiping from the left.
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
Window(Context context)
Public Methods
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).
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)
View findViewById(int id)
Finds a view that was identified by the id attribute from the XML that was processed in onCreate(Bundle).
boolean getAllowEnterTransitionOverlap()
Returns how the transition set in setEnterTransition(android.transition.Transition) overlaps with the exit transition of the calling Activity.
boolean getAllowExitTransitionOverlap()
Returns how the transition set in setExitTransition(android.transition.Transition) overlaps with the exit transition of the called Activity when reentering after if finishes.
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.
Scene getContentScene()
Retrieve the Scene representing this window's current content.
final 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.
Transition getEnterTransition()
Returns the transition used to move Views into the initial scene.
Transition getExitTransition()
Returns the Transition that will be used to move Views out of the scene when starting a new Activity.
abstract LayoutInflater getLayoutInflater()
Quick access to the LayoutInflater instance that this Window retrieved from its Context.
abstract int getNavigationBarColor()
Transition getSharedElementEnterTransition()
Returns the Transition that will be used for shared elements transferred into the content Scene.
Transition getSharedElementExitTransition()
Returns the Transition to use for shared elements in the launching Window prior to transferring to the launched Activity's Window.
abstract int getStatusBarColor()
TransitionManager getTransitionManager()
Retrieve the TransitionManager responsible for for default transitions in this window.
abstract int getVolumeControlStream()
WindowManager getWindowManager()
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 boolean hasChildren()
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)
final boolean isActive()
abstract boolean isFloating()
Return whether this window is being displayed with a floating style (based on the 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.
final void makeActive()
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)
boolean requestFeature(int featureId)
Enable extended screen features.
abstract void restoreHierarchyState(Bundle savedInstanceState)
abstract Bundle saveHierarchyState()
void setAllowEnterTransitionOverlap(boolean allow)
Controls how the transition set in setEnterTransition(android.transition.Transition) overlaps with the exit transition of the calling Activity.
void setAllowExitTransitionOverlap(boolean allow)
Controls how the transition set in setExitTransition(android.transition.Transition) overlaps with the exit transition of the called Activity when reentering after if finishes.
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 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.
void setDimAmount(float amount)
Set the amount of dim behind the window when using FLAG_DIM_BEHIND.
void setEnterTransition(Transition transition)
Sets the Transition that will be used to move Views into the initial scene.
void setExitTransition(Transition transition)
Sets the Transition that will be used to move Views out of the scene when starting a new Activity.
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 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)
Set the logo for this window.
abstract void setNavigationBarColor(int color)
Sets the color of the navigation bar to .
void setSharedElementEnterTransition(Transition transition)
Sets the Transition that will be used for shared elements transferred into the content Scene.
void setSharedElementExitTransition(Transition transition)
Sets the Transition that will be used for shared elements after starting a new Activity before the shared elements are transferred to the called Activity.
void setSoftInputMode(int mode)
Specify an explicit soft input mode to use for the window, as per WindowManager.LayoutParams.softInputMode.
abstract void setStatusBarColor(int color)
Sets the color of the status bar to .
abstract void setTitle(CharSequence title)
abstract void setTitleColor(int textColor)
void setTransitionManager(TransitionManager tm)
Set the TransitionManager to use for default transitions in this window.
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.
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)
Protected Methods
final int getFeatures()
Return the feature bits that are enabled.
final int getForcedWindowFlags()
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 void onActive()
void setDefaultWindowFormat(int format)
Set the default format of window, as per the PixelFormat types.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

protected static final int DEFAULT_FEATURES

Added in API level 1

The default features enabled

Constant Value: 65 (0x00000041)

public static final int FEATURE_ACTION_BAR

Added in API level 11

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.

Constant Value: 8 (0x00000008)

public static final int FEATURE_ACTION_BAR_OVERLAY

Added in API level 11

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.

Constant Value: 9 (0x00000009)

public static final int FEATURE_ACTION_MODE_OVERLAY

Added in API level 11

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.

Constant Value: 10 (0x0000000a)

public static final int FEATURE_CONTENT_TRANSITIONS

Flag for requesting that window content changes should be represented with scenes and transitions. TODO Add docs

Constant Value: 12 (0x0000000c)

public static final int FEATURE_CONTEXT_MENU

Added in API level 1

Flag for the context menu. This is enabled by default.

Constant Value: 6 (0x00000006)

public static final int FEATURE_CUSTOM_TITLE

Added in API level 1

Flag for custom title. You cannot combine this feature with other title features.

Constant Value: 7 (0x00000007)

public static final int FEATURE_INDETERMINATE_PROGRESS

Added in API level 1

Flag for indeterminate progress

Constant Value: 5 (0x00000005)

public static final int FEATURE_LEFT_ICON

Added in API level 1

Flag for having an icon on the left side of the title bar

Constant Value: 3 (0x00000003)

public static final int FEATURE_NO_TITLE

Added in API level 1

Flag for the "no title" feature, turning off the title at the top of the screen.

Constant Value: 1 (0x00000001)

public static final int FEATURE_OPTIONS_PANEL

Added in API level 1

Flag for the "options panel" feature. This is enabled by default.

Constant Value: 0 (0x00000000)

public static final int FEATURE_PROGRESS

Added in API level 1

Flag for the progress indicator feature

Constant Value: 2 (0x00000002)

public static final int FEATURE_RIGHT_ICON

Added in API level 1

Flag for having an icon on the right side of the title bar

Constant Value: 4 (0x00000004)

public static final int FEATURE_SWIPE_TO_DISMISS

Flag for requesting a decoration-free window that is dismissed by swiping from the left.

Constant Value: 11 (0x0000000b)

public static final int ID_ANDROID_CONTENT

Added in API level 1

The ID that the main layout in the XML layout file should have.

Constant Value: 16908290 (0x01020002)

public static final int PROGRESS_END

Added in API level 1

Ending value for the (primary) progress

Constant Value: 10000 (0x00002710)

public static final int PROGRESS_INDETERMINATE_OFF

Added in API level 1

Flag for setting the progress bar's indeterminate mode off

Constant Value: -4 (0xfffffffc)

public static final int PROGRESS_INDETERMINATE_ON

Added in API level 1

Flag for setting the progress bar's indeterminate mode on

Constant Value: -3 (0xfffffffd)

public static final int PROGRESS_SECONDARY_END

Added in API level 1

Highest possible value for the secondary progress

Constant Value: 30000 (0x00007530)

public static final int PROGRESS_SECONDARY_START

Added in API level 1

Lowest possible value for the secondary progress

Constant Value: 20000 (0x00004e20)

public static final int PROGRESS_START

Added in API level 1

Starting value for the (primary) progress

Constant Value: 0 (0x00000000)

public static final int PROGRESS_VISIBILITY_OFF

Added in API level 1

Flag for setting the progress bar's visibility to GONE

Constant Value: -2 (0xfffffffe)

public static final int PROGRESS_VISIBILITY_ON

Added in API level 1

Flag for setting the progress bar's visibility to VISIBLE

Constant Value: -1 (0xffffffff)

Public Constructors

public Window (Context context)

Added in API level 1

Public Methods

public abstract void addContentView (View view, ViewGroup.LayoutParams params)

Added in API level 1

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.

Parameters
view The desired content to display.
params Layout parameters for the view.

public void addFlags (int flags)

Added in API level 1

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

Parameters
flags The flag bits to be set.

public void clearFlags (int flags)

Added in API level 1

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

Parameters
flags The flag bits to be cleared.

public abstract void closeAllPanels ()

Added in API level 1

public abstract void closePanel (int featureId)

Added in API level 1

public View findViewById (int id)

Added in API level 1

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.

Returns
  • The view if found or null otherwise.

public boolean getAllowEnterTransitionOverlap ()

Returns how the transition set in setEnterTransition(android.transition.Transition) overlaps with the exit transition of the calling Activity. When true, the transition will start as soon as possible. When false, the transition will wait until the remote exiting transition completes before starting.

Returns
  • true when the enter transition should start as soon as possible or false to when it should wait until the exiting transition completes.

public boolean getAllowExitTransitionOverlap ()

Returns how the transition set in setExitTransition(android.transition.Transition) overlaps with the exit transition of the called Activity when reentering after if finishes. When true, the transition will start as soon as possible. When false, the transition will wait until the called Activity's exiting transition completes before starting.

Returns
  • true when the transition should start when possible or false when it should wait until the called Activity's exiting transition completes.

public final WindowManager.LayoutParams getAttributes ()

Added in API level 1

Retrieve the current window attributes associated with this panel.

Returns
  • WindowManager.LayoutParams Either the existing window attributes object, or a freshly created one if there is none.

public final Window.Callback getCallback ()

Added in API level 1

Return the current Callback interface for this window.

public final Window getContainer ()

Added in API level 1

Return the container for this Window.

Returns
  • Window The containing window, or null if this is a top-level window.

public Scene getContentScene ()

Retrieve the Scene representing this window's current content. Requires FEATURE_CONTENT_TRANSITIONS.

This method will return null if the current content is not represented by a Scene.

Returns
  • Current Scene being shown or null

public final Context getContext ()

Added in API level 1

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

Returns
  • Context The Context that was supplied to the constructor.

public abstract View getCurrentFocus ()

Added in API level 1

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.

Returns
  • View The current View with focus or null.

public abstract View getDecorView ()

Added in API level 1

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

Returns
  • Returns the top-level window decor view.

public Transition getEnterTransition ()

Returns the transition used to move Views into the initial scene. The entering Views will be those that are regular Views or ViewGroups that have isTransitionGroup() return true. Typical Transitions will extend Visibility as entering is governed by changing visibility from INVISIBLE to VISIBLE. If transition is null, entering Views will remain unaffected. Requires FEATURE_CONTENT_TRANSITIONS.

Returns
  • the Transition to use to move Views into the initial Scene.

public Transition getExitTransition ()

Returns the Transition that will be used to move Views out of the scene when starting a new Activity. The exiting Views will be those that are regular Views or ViewGroups that have isTransitionGroup() return true. Typical Transitions will extend Visibility as exiting is governed by changing visibility from VISIBLE to INVISIBLE. If transition is null, the views will remain unaffected. Requires FEATURE_CONTENT_TRANSITIONS.

Returns
  • the Transition to use to move Views out of the scene when calling a new Activity.

public abstract LayoutInflater getLayoutInflater ()

Added in API level 1

Quick access to the LayoutInflater instance that this Window retrieved from its Context.

Returns
  • LayoutInflater The shared LayoutInflater.

public abstract int getNavigationBarColor ()

Returns
  • the color of the navigation bar.

public Transition getSharedElementEnterTransition ()

Returns the Transition that will be used for shared elements transferred into the content Scene. Requires FEATURE_CONTENT_TRANSITIONS.

Returns
  • Transition to use for sharend elements transferred into the content Scene.

public Transition getSharedElementExitTransition ()

Returns the Transition to use for shared elements in the launching Window prior to transferring to the launched Activity's Window. Requires FEATURE_CONTENT_TRANSITIONS.

Returns
  • the Transition to use for shared elements in the launching Window prior to transferring to the launched Activity's Window.

public abstract int getStatusBarColor ()

Returns
  • the color of the status bar.

public TransitionManager getTransitionManager ()

Retrieve the TransitionManager responsible for for default transitions in this window. Requires FEATURE_CONTENT_TRANSITIONS.

This method will return non-null after content has been initialized (e.g. by using setContentView(View)) if FEATURE_CONTENT_TRANSITIONS has been granted.

Returns
  • This window's content TransitionManager or null if none is set.

public abstract int getVolumeControlStream ()

Added in API level 1

public WindowManager getWindowManager ()

Added in API level 1

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

Returns
  • WindowManager The ViewManager.

public final TypedArray getWindowStyle ()

Added in API level 1

Return the Window attributes from this window's theme.

public final boolean hasChildren ()

Added in API level 1

public boolean hasFeature (int feature)

Added in API level 11

Query for the availability of a certain feature.

Parameters
feature The feature ID to check
Returns
  • true if the feature is enabled, false otherwise.

public void injectInputEvent (InputEvent event)

Added in API level 19

Inject an event to window locally.

Parameters
event A key or touch event to inject to this window.

public abstract void invalidatePanelMenu (int featureId)

Added in API level 11

public final boolean isActive ()

Added in API level 1

public abstract boolean isFloating ()

Added in API level 1

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

Returns
  • Returns true if the window is configured to be displayed floating on top of whatever is behind it.

public abstract boolean isShortcutKey (int keyCode, KeyEvent event)

Added in API level 1

Is a keypress one of the defined shortcut keys for this window.

Parameters
keyCode the key code from KeyEvent to check.
event the KeyEvent to use to help check.

public final void makeActive ()

Added in API level 1

public abstract void onConfigurationChanged (Configuration newConfig)

Added in API level 1

Should be called when the configuration is changed.

Parameters
newConfig The new configuration.

public abstract void openPanel (int featureId, KeyEvent event)

Added in API level 1

public abstract View peekDecorView ()

Added in API level 1

Retrieve the current decor view, but only if it has already been created; otherwise returns null.

Returns
  • Returns the top-level window decor or null.
See Also

public abstract boolean performContextMenuIdentifierAction (int id, int flags)

Added in API level 1

public abstract boolean performPanelIdentifierAction (int featureId, int id, int flags)

Added in API level 1

public abstract boolean performPanelShortcut (int featureId, int keyCode, KeyEvent event, int flags)

Added in API level 1

public boolean requestFeature (int featureId)

Added in API level 1

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.

Parameters
featureId The desired features, defined as constants by Window.
Returns
  • The features that are now set.

public abstract void restoreHierarchyState (Bundle savedInstanceState)

Added in API level 1

public abstract Bundle saveHierarchyState ()

Added in API level 1

public void setAllowEnterTransitionOverlap (boolean allow)

Controls how the transition set in setEnterTransition(android.transition.Transition) overlaps with the exit transition of the calling Activity. When true, the transition will start as soon as possible. When false, the transition will wait until the remote exiting transition completes before starting.

Parameters
allow true to start the enter transition when possible or false to wait until the exiting transition completes.

public void setAllowExitTransitionOverlap (boolean allow)

Controls how the transition set in setExitTransition(android.transition.Transition) overlaps with the exit transition of the called Activity when reentering after if finishes. When true, the transition will start as soon as possible. When false, the transition will wait until the called Activity's exiting transition completes before starting.

Parameters
allow true to start the transition when possible or false to wait until the called Activity's exiting transition completes.

public void setAttributes (WindowManager.LayoutParams a)

Added in API level 1

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.

Parameters
a The new window attributes, which will completely override any current values.

public abstract void setBackgroundDrawable (Drawable drawable)

Added in API level 1

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

Parameters
drawable The new Drawable to use for this window's background.

public void setBackgroundDrawableResource (int resid)

Added in API level 1

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

Parameters
resid The resource identifier of a drawable resource which will be installed as the new background.

public void setCallback (Window.Callback callback)

Added in API level 1

Set the Callback interface for this window, used to intercept key events and other dynamic operations in the window.

Parameters
callback The desired Callback interface.

public abstract void setChildDrawable (int featureId, Drawable drawable)

Added in API level 1

public abstract void setChildInt (int featureId, int value)

Added in API level 1

public void setContainer (Window container)

Added in API level 1

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.

Parameters
container The desired containing Window.

public abstract void setContentView (int layoutResID)

Added in API level 1

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.

Parameters
layoutResID Resource ID to be inflated.

public abstract void setContentView (View view)

Added in API level 1

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.

Parameters
view The desired content to display.

public abstract void setContentView (View view, ViewGroup.LayoutParams params)

Added in API level 1

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

Parameters
view The desired content to display.
params Layout parameters for the view.

public void setDimAmount (float amount)

Added in API level 14

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.

Parameters
amount The new dim amount, from 0 for no dim to 1 for full dim.

public void setEnterTransition (Transition transition)

Sets the Transition that will be used to move Views into the initial scene. The entering Views will be those that are regular Views or ViewGroups that have isTransitionGroup() return true. Typical Transitions will extend Visibility as entering is governed by changing visibility from INVISIBLE to VISIBLE. If transition is null, entering Views will remain unaffected.

Parameters
transition The Transition to use to move Views into the initial Scene.

public void setExitTransition (Transition transition)

Sets the Transition that will be used to move Views out of the scene when starting a new Activity. The exiting Views will be those that are regular Views or ViewGroups that have isTransitionGroup() return true. Typical Transitions will extend Visibility as exiting is governed by changing visibility from VISIBLE to INVISIBLE. If transition is null, the views will remain unaffected. Requires FEATURE_CONTENT_TRANSITIONS.

Parameters
transition The Transition to use to move Views out of the scene when calling a new Activity.

public abstract void setFeatureDrawable (int featureId, Drawable drawable)

Added in API level 1

Set an explicit Drawable value for feature of this window. You must have called requestFeature(featureId) before calling this function.

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

Added in API level 1

Set a custom alpha value for the given drawale feature, controlling how much the background is visible through it.

Parameters
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 setFeatureDrawableResource (int featureId, int resId)

Added in API level 1

Set the value for a drawable feature of this window, from a resource identifier. You must have called requestFeauture(featureId) before calling this function.

Parameters
featureId The desired drawable feature to change, defined as a constant by Window.
resId Resource identifier of the desired image.
See Also

public abstract void setFeatureDrawableUri (int featureId, Uri uri)

Added in API level 1

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.

Parameters
featureId The desired drawable feature to change. Features are constants defined by Window.
uri The desired URI.
See Also

public abstract void setFeatureInt (int featureId, int value)

Added in API level 1

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.

Parameters
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 void setFlags (int flags, int mask)

Added in API level 1

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.

Parameters
flags The new window flags (see WindowManager.LayoutParams).
mask Which of the window flag bits to modify.

public void setFormat (int format)

Added in API level 1

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.

Parameters
format The new window format (see PixelFormat). Use PixelFormat.UNKNOWN to allow the Window to select the format.
See Also

public void setGravity (int gravity)

Added in API level 1

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.

Parameters
gravity The desired gravity constant.

public void setIcon (int resId)

Added in API level 19

Set the primary icon for this window.

Parameters
resId resource ID of a drawable to set

public void setLayout (int width, int height)

Added in API level 1

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.

Parameters
width The desired layout width of the window.
height The desired layout height of the window.
See Also

public void setLocalFocus (boolean hasFocus, boolean inTouchMode)

Added in API level 19

Set focus locally. The window should have the FLAG_LOCAL_FOCUS_MODE flag set already.

Parameters
hasFocus Whether this window has focus or not.
inTouchMode Whether this window is in touch mode or not.

public void setLogo (int resId)

Added in API level 19

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.

Parameters
resId resource ID of a drawable to set

public abstract void setNavigationBarColor (int color)

Sets the color of the navigation bar to . For this to take effect, the window must be drawing the system bar backgrounds with FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS and FLAG_TRANSLUCENT_NAVIGATION must not be set. If is not opaque, consider setting SYSTEM_UI_FLAG_LAYOUT_STABLE and SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION.

public void setSharedElementEnterTransition (Transition transition)

Sets the Transition that will be used for shared elements transferred into the content Scene. Typical Transitions will affect size and location, such as MoveImage and ChangeBounds. A null value will cause transferred shared elements to blink to the final position. Requires FEATURE_CONTENT_TRANSITIONS.

Parameters
transition The Transition to use for shared elements transferred into the content Scene.

public void setSharedElementExitTransition (Transition transition)

Sets the Transition that will be used for shared elements after starting a new Activity before the shared elements are transferred to the called Activity. If the shared elements must animate during the exit transition, this Transition should be used. Upon completion, the shared elements may be transferred to the started Activity. Requires FEATURE_CONTENT_TRANSITIONS.

Parameters
transition The Transition to use for shared elements in the launching Window prior to transferring to the launched Activity's Window.

public void setSoftInputMode (int mode)

Added in API level 3

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.

public abstract void setStatusBarColor (int color)

Sets the color of the status bar to . For this to take effect, the window must be drawing the system bar backgrounds with FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS and FLAG_TRANSLUCENT_STATUS must not be set. If is not opaque, consider setting SYSTEM_UI_FLAG_LAYOUT_STABLE and SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN.

public abstract void setTitle (CharSequence title)

Added in API level 1

public abstract void setTitleColor (int textColor)

Added in API level 1

public void setTransitionManager (TransitionManager tm)

Set the TransitionManager to use for default transitions in this window. Requires FEATURE_CONTENT_TRANSITIONS.

Parameters
tm The TransitionManager to use for scene changes.

public void setType (int type)

Added in API level 1

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

Parameters
type The new window type (see WindowManager.LayoutParams).

public void setUiOptions (int uiOptions)

Added in API level 14

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

Parameters
uiOptions Flags specifying extra options for this window.

public void setUiOptions (int uiOptions, int mask)

Added in API level 14

Set extra options that will influence the UI for this window. Only the bits filtered by mask will be modified.

Parameters
uiOptions Flags specifying extra options for this window.
mask Flags specifying which options should be modified. Others will remain unchanged.

public abstract void setVolumeControlStream (int streamType)

Added in API level 1

public void setWindowAnimations (int resId)

Added in API level 3

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.

public void setWindowManager (WindowManager wm, IBinder appToken, String appName)

Added in API level 1

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.

Parameters
wm The window manager for adding new windows.

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

Added in API level 11

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.

Parameters
wm The window manager for adding new windows.

public abstract boolean superDispatchGenericMotionEvent (MotionEvent event)

Added in API level 12

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.

public abstract boolean superDispatchKeyEvent (KeyEvent event)

Added in API level 1

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.

public abstract boolean superDispatchKeyShortcutEvent (KeyEvent event)

Added in API level 11

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.

public abstract boolean superDispatchTouchEvent (MotionEvent event)

Added in API level 1

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.

public abstract boolean superDispatchTrackballEvent (MotionEvent event)

Added in API level 1

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.

public abstract void takeInputQueue (InputQueue.Callback callback)

Added in API level 9

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.

public abstract void takeKeyEvents (boolean get)

Added in API level 1

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.

public abstract void takeSurface (SurfaceHolder.Callback2 callback)

Added in API level 9

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.

public abstract void togglePanel (int featureId, KeyEvent event)

Added in API level 1

Protected Methods

protected final int getFeatures ()

Added in API level 1

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.

Returns
  • int The feature bits.

protected final int getForcedWindowFlags ()

Added in API level 1

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

protected final int getLocalFeatures ()

Added in API level 1

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.

Returns
  • int The feature bits.

protected final boolean hasSoftInputMode ()

Added in API level 3

Has the app specified their own soft input mode?

protected abstract void onActive ()

Added in API level 1

protected void setDefaultWindowFormat (int format)

Added in API level 1

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

Parameters
format The new window format (see PixelFormat).