IT. Expert System.

Android Reference

Window


android.view

Class Window



  • public abstract class Window
    extends Object
    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.

    • Field Detail

      • FEATURE_OPTIONS_PANEL

        public static final int FEATURE_OPTIONS_PANEL
        Flag for the "options panel" feature. This is enabled by default.
        See Also:
        Constant Field Values
      • FEATURE_NO_TITLE

        public static final int FEATURE_NO_TITLE
        Flag for the "no title" feature, turning off the title at the top of the screen.
        See Also:
        Constant Field Values
      • FEATURE_PROGRESS

        public static final int FEATURE_PROGRESS
        Flag for the progress indicator feature
        See Also:
        Constant Field Values
      • FEATURE_LEFT_ICON

        public static final int FEATURE_LEFT_ICON
        Flag for having an icon on the left side of the title bar
        See Also:
        Constant Field Values
      • FEATURE_RIGHT_ICON

        public static final int FEATURE_RIGHT_ICON
        Flag for having an icon on the right side of the title bar
        See Also:
        Constant Field Values
      • FEATURE_INDETERMINATE_PROGRESS

        public static final int FEATURE_INDETERMINATE_PROGRESS
        Flag for indeterminate progress
        See Also:
        Constant Field Values
      • FEATURE_CONTEXT_MENU

        public static final int FEATURE_CONTEXT_MENU
        Flag for the context menu. This is enabled by default.
        See Also:
        Constant Field Values
      • FEATURE_CUSTOM_TITLE

        public static final int FEATURE_CUSTOM_TITLE
        Flag for custom title. You cannot combine this feature with other title features.
        See Also:
        Constant Field Values
      • FEATURE_ACTION_BAR

        public static final int FEATURE_ACTION_BAR
        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.
        See Also:
        Constant Field Values
      • FEATURE_ACTION_BAR_OVERLAY

        public static final int FEATURE_ACTION_BAR_OVERLAY
        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 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.

        See Also:
        Constant Field Values
      • FEATURE_ACTION_MODE_OVERLAY

        public static final int FEATURE_ACTION_MODE_OVERLAY
        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.
        See Also:
        Constant Field Values
      • FEATURE_MAX

        public static final int FEATURE_MAX
        Max value used as a feature ID
        See Also:
        Constant Field Values
      • PROGRESS_VISIBILITY_ON

        public static final int PROGRESS_VISIBILITY_ON
        Flag for setting the progress bar's visibility to VISIBLE
        See Also:
        Constant Field Values
      • PROGRESS_VISIBILITY_OFF

        public static final int PROGRESS_VISIBILITY_OFF
        Flag for setting the progress bar's visibility to GONE
        See Also:
        Constant Field Values
      • PROGRESS_INDETERMINATE_ON

        public static final int PROGRESS_INDETERMINATE_ON
        Flag for setting the progress bar's indeterminate mode on
        See Also:
        Constant Field Values
      • PROGRESS_INDETERMINATE_OFF

        public static final int PROGRESS_INDETERMINATE_OFF
        Flag for setting the progress bar's indeterminate mode off
        See Also:
        Constant Field Values
      • PROGRESS_START

        public static final int PROGRESS_START
        Starting value for the (primary) progress
        See Also:
        Constant Field Values
      • PROGRESS_END

        public static final int PROGRESS_END
        Ending value for the (primary) progress
        See Also:
        Constant Field Values
      • PROGRESS_SECONDARY_START

        public static final int PROGRESS_SECONDARY_START
        Lowest possible value for the secondary progress
        See Also:
        Constant Field Values
      • PROGRESS_SECONDARY_END

        public static final int PROGRESS_SECONDARY_END
        Highest possible value for the secondary progress
        See Also:
        Constant Field Values
      • DEFAULT_FEATURES

        protected static final int DEFAULT_FEATURES
        The default features enabled
        See Also:
        Constant Field Values
      • ID_ANDROID_CONTENT

        public static final int ID_ANDROID_CONTENT
        The ID that the main layout in the XML layout file should have.
    • Constructor Detail

      • Window

        public Window(Context context)
    • Method Detail

      • getContext

        public final Context getContext()
        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.
      • getWindowStyle

        public final TypedArray getWindowStyle()
        Return the android.R.styleable#Window attributes from this window's theme.
      • setContainer

        public void setContainer(Window container)
        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.
      • getContainer

        public final Window getContainer()
        Return the container for this Window.
        Returns:
        Window The containing window, or null if this is a top-level window.
      • hasChildren

        public final boolean hasChildren()
      • destroy

        public final void destroy()
      • isDestroyed

        public final boolean isDestroyed()
      • setWindowManager

        public void setWindowManager(WindowManager wm,
                            IBinder appToken,
                            String appName)
        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.
      • setWindowManager

        public void setWindowManager(WindowManager wm,
                            IBinder appToken,
                            String appName,
                            boolean hardwareAccelerated)
        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.
      • getWindowManager

        public WindowManager getWindowManager()
        Return the window manager allowing this Window to display its own windows.
        Returns:
        WindowManager The ViewManager.
      • setCallback

        public void setCallback(Window.Callback callback)
        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.
      • getCallback

        public final Window.Callback getCallback()
        Return the current Callback interface for this window.
      • takeSurface

        public abstract void takeSurface(SurfaceHolder.Callback2 callback)
        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.
      • takeInputQueue

        public abstract void takeInputQueue(InputQueue.Callback callback)
        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.
      • isFloating

        public 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).
        Returns:
        Returns true if the window is configured to be displayed floating on top of whatever is behind it.
      • setLayout

        public void setLayout(int width,
                     int height)
        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:
        ViewGroup.LayoutParams.height, ViewGroup.LayoutParams.width
      • setGravity

        public void setGravity(int gravity)
        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.
        See Also:
        Gravity, setLayout(int, int)
      • setType

        public void setType(int type)
        Set the type of the window, as per the WindowManager.LayoutParams types.
        Parameters:
        type - The new window type (see WindowManager.LayoutParams).
      • setFormat

        public void setFormat(int format)
        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:
        PixelFormat
      • setWindowAnimations

        public void setWindowAnimations(int resId)
        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.
      • setSoftInputMode

        public void setSoftInputMode(int mode)
        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.
      • setDimAmount

        public void setDimAmount(float amount)
        Set the amount of dim behind the window when using WindowManager.LayoutParams.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.
      • setAttributes

        public void setAttributes(WindowManager.LayoutParams a)
        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.
      • getAttributes

        public final WindowManager.LayoutParams getAttributes()
        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.
      • getForcedWindowFlags

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

        protected final boolean hasSoftInputMode()
        Has the app specified their own soft input mode?
      • setCloseOnTouchOutside

        public void setCloseOnTouchOutside(boolean close)
      • setCloseOnTouchOutsideIfNotSet

        public void setCloseOnTouchOutsideIfNotSet(boolean close)
      • alwaysReadCloseOnTouchAttr

        public abstract void alwaysReadCloseOnTouchAttr()
      • shouldCloseOnTouch

        public boolean shouldCloseOnTouch(Context context,
                                 MotionEvent event)
      • requestFeature

        public boolean requestFeature(int featureId)
        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.
      • removeFeature

        protected void removeFeature(int featureId)
      • makeActive

        public final void makeActive()
      • isActive

        public final boolean isActive()
      • findViewById

        public 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). This will implicitly call getDecorView() for you, with all of the associated side-effects.
        Returns:
        The view if found or null otherwise.
      • setContentView

        public abstract void setContentView(View view,
                          ViewGroup.LayoutParams params)
        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.
      • getCurrentFocus

        public abstract View getCurrentFocus()
        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.
      • getLayoutInflater

        public abstract LayoutInflater getLayoutInflater()
        Quick access to the LayoutInflater instance that this Window retrieved from its Context.
        Returns:
        LayoutInflater The shared LayoutInflater.
      • setTitle

        public abstract void setTitle(CharSequence title)
      • setTitleColor

        public abstract void setTitleColor(int textColor)
      • openPanel

        public abstract void openPanel(int featureId,
                     KeyEvent event)
      • closePanel

        public abstract void closePanel(int featureId)
      • togglePanel

        public abstract void togglePanel(int featureId,
                       KeyEvent event)
      • invalidatePanelMenu

        public abstract void invalidatePanelMenu(int featureId)
      • performPanelShortcut

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

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

        public abstract void closeAllPanels()
      • performContextMenuIdentifierAction

        public abstract boolean performContextMenuIdentifierAction(int id,
                                                 int flags)
      • onConfigurationChanged

        public abstract void onConfigurationChanged(Configuration newConfig)
        Should be called when the configuration is changed.
        Parameters:
        newConfig - The new configuration.
      • setBackgroundDrawableResource

        public void setBackgroundDrawableResource(int resid)
        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.
      • setBackgroundDrawable

        public abstract void setBackgroundDrawable(Drawable drawable)
        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.
      • setFeatureDrawableResource

        public abstract void setFeatureDrawableResource(int featureId,
                                      int resId)
        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:
        Resources.getDrawable(int)
      • setFeatureDrawableUri

        public abstract void setFeatureDrawableUri(int featureId,
                                 Uri uri)
        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:
        ImageView.setImageURI(android.net.Uri)
      • setFeatureDrawable

        public abstract void setFeatureDrawable(int featureId,
                              Drawable drawable)
        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.
      • setFeatureDrawableAlpha

        public 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.
        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.
      • setFeatureInt

        public abstract void setFeatureInt(int featureId,
                         int value)
        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.
      • takeKeyEvents

        public abstract void takeKeyEvents(boolean get)
        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.
      • superDispatchKeyEvent

        public abstract boolean superDispatchKeyEvent(KeyEvent event)
        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.
      • superDispatchKeyShortcutEvent

        public abstract boolean superDispatchKeyShortcutEvent(KeyEvent event)
        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.
      • superDispatchTouchEvent

        public abstract boolean superDispatchTouchEvent(MotionEvent event)
        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.
      • superDispatchTrackballEvent

        public abstract boolean superDispatchTrackballEvent(MotionEvent event)
        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.
      • superDispatchGenericMotionEvent

        public abstract boolean superDispatchGenericMotionEvent(MotionEvent event)
        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.
      • getDecorView

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

        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.
      • peekDecorView

        public abstract View peekDecorView()
        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:
        getDecorView()
      • saveHierarchyState

        public abstract Bundle saveHierarchyState()
      • restoreHierarchyState

        public abstract void restoreHierarchyState(Bundle savedInstanceState)
      • onActive

        protected abstract void onActive()
      • getFeatures

        protected final int getFeatures()
        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.
      • hasFeature

        public boolean hasFeature(int feature)
        Query for the availability of a certain feature.
        Parameters:
        feature - The feature ID to check
        Returns:
        true if the feature is enabled, false otherwise.
      • getLocalFeatures

        protected final int getLocalFeatures()
        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.
      • setDefaultWindowFormat

        protected void setDefaultWindowFormat(int format)
        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).
        See Also:
        setFormat(int), PixelFormat
      • haveDimAmount

        protected boolean haveDimAmount()
      • setChildDrawable

        public abstract void setChildDrawable(int featureId,
                            Drawable drawable)
      • setChildInt

        public abstract void setChildInt(int featureId,
                       int value)
      • isShortcutKey

        public abstract boolean isShortcutKey(int keyCode,
                            KeyEvent event)
        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.
      • setUiOptions

        public void setUiOptions(int uiOptions)
        Set extra options that will influence the UI for this window.
        Parameters:
        uiOptions - Flags specifying extra options for this window.
      • setUiOptions

        public void setUiOptions(int uiOptions,
                        int mask)
        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.


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 1051 / . Delta: 0.01468 с