IT. Expert System.

Android Reference

View


android.view

Class View

  • All Implemented Interfaces:
    Drawable.Callback, AccessibilityEventSource, KeyEvent.Callback
    Direct Known Subclasses:
    AnalogClock, CreateViewTest.ViewOne, ImageView, InflateTest.ViewOne, InternalSelectionView, KeyboardView, LabelView, MediaRouteButton, MockView, ProgressBar, Space, Space, TextureView, TextView, ViewAttachView, ViewGroup, ViewStub


    public class View
    extends Object
    implements Drawable.Callback, KeyEvent.Callback, AccessibilityEventSource

    This class represents the basic building block for user interface components. A View occupies a rectangular area on the screen and is responsible for drawing and event handling. View is the base class for widgets, which are used to create interactive UI components (buttons, text fields, etc.). The ViewGroup subclass is the base class for layouts, which are invisible containers that hold other Views (or other ViewGroups) and define their layout properties.

    Developer Guides

    For information about using this class to develop your application's user interface, read the User Interface developer guide.

    Using Views

    All of the views in a window are arranged in a single tree. You can add views either from code or by specifying a tree of views in one or more XML layout files. There are many specialized subclasses of views that act as controls or are capable of displaying text, images, or other content.

    Once you have created a tree of views, there are typically a few types of common operations you may wish to perform:

    • Set properties: for example setting the text of a TextView. The available properties and the methods that set them will vary among the different subclasses of views. Note that properties that are known at build time can be set in the XML layout files.
    • Set focus: The framework will handled moving focus in response to user input. To force focus to a specific view, call requestFocus().
    • Set up listeners: Views allow clients to set listeners that will be notified when something interesting happens to the view. For example, all views will let you set a listener to be notified when the view gains or loses focus. You can register such a listener using setOnFocusChangeListener(android.view.View.OnFocusChangeListener). Other view subclasses offer more specialized listeners. For example, a Button exposes a listener to notify clients when the button is clicked.
    • Set visibility: You can hide or show views using setVisibility(int).

    Note: The Android framework is responsible for measuring, laying out and drawing views. You should not call methods that perform these actions on views yourself unless you are actually implementing a ViewGroup.

    Implementing a Custom View

    To implement a custom view, you will usually begin by providing overrides for some of the standard methods that the framework calls on all views. You do not need to override all of these methods. In fact, you can start by just overriding onDraw(android.graphics.Canvas).

    Category Methods Description
    Creation Constructors There is a form of the constructor that are called when the view is created from code and a form that is called when the view is inflated from a layout file. The second form should parse and apply any attributes defined in the layout file.
    onFinishInflate() Called after a view and all of its children has been inflated from XML.
    Layout onMeasure(int, int) Called to determine the size requirements for this view and all of its children.
    onLayout(boolean, int, int, int, int) Called when this view should assign a size and position to all of its children.
    onSizeChanged(int, int, int, int) Called when the size of this view has changed.
    Drawing onDraw(android.graphics.Canvas) Called when the view should render its content.
    Event processing onKeyDown(int, KeyEvent) Called when a new hardware key event occurs.
    onKeyUp(int, KeyEvent) Called when a hardware key up event occurs.
    onTrackballEvent(MotionEvent) Called when a trackball motion event occurs.
    onTouchEvent(MotionEvent) Called when a touch screen motion event occurs.
    Focus onFocusChanged(boolean, int, android.graphics.Rect) Called when the view gains or loses focus.
    onWindowFocusChanged(boolean) Called when the window containing the view gains or loses focus.
    Attaching onAttachedToWindow() Called when the view is attached to a window.
    onDetachedFromWindow() Called when the view is detached from its window.
    onWindowVisibilityChanged(int) Called when the visibility of the window containing the view has changed.

    IDs

    Views may have an integer id associated with them. These ids are typically assigned in the layout XML files, and are used to find specific views within the view tree. A common pattern is to:
    • Define a Button in the layout file and assign it a unique ID.
       <Button
           android:id="@+id/my_button"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:text="@string/my_button_text"/>
       
    • From the onCreate method of an Activity, find the Button
            Button myButton = (Button) findViewById(R.id.my_button);
       

    View IDs need not be unique throughout the tree, but it is good practice to ensure that they are at least unique within the part of the tree you are searching.

    Position

    The geometry of a view is that of a rectangle. A view has a location, expressed as a pair of left and top coordinates, and two dimensions, expressed as a width and a height. The unit for location and dimensions is the pixel.

    It is possible to retrieve the location of a view by invoking the methods getLeft() and getTop(). The former returns the left, or X, coordinate of the rectangle representing the view. The latter returns the top, or Y, coordinate of the rectangle representing the view. These methods both return the location of the view relative to its parent. For instance, when getLeft() returns 20, that means the view is located 20 pixels to the right of the left edge of its direct parent.

    In addition, several convenience methods are offered to avoid unnecessary computations, namely getRight() and getBottom(). These methods return the coordinates of the right and bottom edges of the rectangle representing the view. For instance, calling getRight() is similar to the following computation: getLeft() + getWidth() (see Size for more information about the width.)

    Size, padding and margins

    The size of a view is expressed with a width and a height. A view actually possess two pairs of width and height values.

    The first pair is known as measured width and measured height. These dimensions define how big a view wants to be within its parent (see Layout for more details.) The measured dimensions can be obtained by calling getMeasuredWidth() and getMeasuredHeight().

    The second pair is simply known as width and height, or sometimes drawing width and drawing height. These dimensions define the actual size of the view on screen, at drawing time and after layout. These values may, but do not have to, be different from the measured width and height. The width and height can be obtained by calling getWidth() and getHeight().

    To measure its dimensions, a view takes into account its padding. The padding is expressed in pixels for the left, top, right and bottom parts of the view. Padding can be used to offset the content of the view by a specific amount of pixels. For instance, a left padding of 2 will push the view's content by 2 pixels to the right of the left edge. Padding can be set using the setPadding(int, int, int, int) or setPaddingRelative(int, int, int, int) method and queried by calling getPaddingLeft(), getPaddingTop(), getPaddingRight(), getPaddingBottom(), getPaddingStart(), getPaddingEnd().

    Even though a view can define a padding, it does not provide any support for margins. However, view groups provide such a support. Refer to ViewGroup and ViewGroup.MarginLayoutParams for further information.

    Layout

    Layout is a two pass process: a measure pass and a layout pass. The measuring pass is implemented in measure(int, int) and is a top-down traversal of the view tree. Each view pushes dimension specifications down the tree during the recursion. At the end of the measure pass, every view has stored its measurements. The second pass happens in layout(int,int,int,int) and is also top-down. During this pass each parent is responsible for positioning all of its children using the sizes computed in the measure pass.

    When a view's measure() method returns, its getMeasuredWidth() and getMeasuredHeight() values must be set, along with those for all of that view's descendants. A view's measured width and measured height values must respect the constraints imposed by the view's parents. This guarantees that at the end of the measure pass, all parents accept all of their children's measurements. A parent view may call measure() more than once on its children. For example, the parent may measure each child once with unspecified dimensions to find out how big they want to be, then call measure() on them again with actual numbers if the sum of all the children's unconstrained sizes is too big or too small.

    The measure pass uses two classes to communicate dimensions. The View.MeasureSpec class is used by views to tell their parents how they want to be measured and positioned. The base LayoutParams class just describes how big the view wants to be for both width and height. For each dimension, it can specify one of:

    • an exact number
    • MATCH_PARENT, which means the view wants to be as big as its parent (minus padding)
    • WRAP_CONTENT, which means that the view wants to be just big enough to enclose its content (plus padding).
    There are subclasses of LayoutParams for different subclasses of ViewGroup. For example, AbsoluteLayout has its own subclass of LayoutParams which adds an X and Y value.

    MeasureSpecs are used to push requirements down the tree from parent to child. A MeasureSpec can be in one of three modes:

    • UNSPECIFIED: This is used by a parent to determine the desired dimension of a child view. For example, a LinearLayout may call measure() on its child with the height set to UNSPECIFIED and a width of EXACTLY 240 to find out how tall the child view wants to be given a width of 240 pixels.
    • EXACTLY: This is used by the parent to impose an exact size on the child. The child must use this size, and guarantee that all of its descendants will fit within this size.
    • AT_MOST: This is used by the parent to impose a maximum size on the child. The child must gurantee that it and all of its descendants will fit within this size.

    To intiate a layout, call requestLayout(). This method is typically called by a view on itself when it believes that is can no longer fit within its current bounds.

    Drawing

    Drawing is handled by walking the tree and rendering each view that intersects the invalid region. Because the tree is traversed in-order, this means that parents will draw before (i.e., behind) their children, with siblings drawn in the order they appear in the tree. If you set a background drawable for a View, then the View will draw it for you before calling back to its onDraw() method.

    Note that the framework will not draw views that are not in the invalid region.

    To force a view to draw, call invalidate().

    Event Handling and Threading

    The basic cycle of a view is as follows:

    1. An event comes in and is dispatched to the appropriate view. The view handles the event and notifies any listeners.
    2. If in the course of processing the event, the view's bounds may need to be changed, the view will call requestLayout().
    3. Similarly, if in the course of processing the event the view's appearance may need to be changed, the view will call invalidate().
    4. If either requestLayout() or invalidate() were called, the framework will take care of measuring, laying out, and drawing the tree as appropriate.

    Note: The entire view tree is single threaded. You must always be on the UI thread when calling any method on any view. If you are doing work on other threads and want to update the state of a view from that thread, you should use a Handler.

    Focus Handling

    The framework will handle routine focus movement in response to user input. This includes changing the focus as views are removed or hidden, or as new views become available. Views indicate their willingness to take focus through the isFocusable() method. To change whether a view can take focus, call setFocusable(boolean). When in touch mode (see notes below) views indicate whether they still would like focus via isFocusableInTouchMode() and can change this via setFocusableInTouchMode(boolean).

    Focus movement is based on an algorithm which finds the nearest neighbor in a given direction. In rare cases, the default algorithm may not match the intended behavior of the developer. In these situations, you can provide explicit overrides by using these XML attributes in the layout file:

     nextFocusDown
     nextFocusLeft
     nextFocusRight
     nextFocusUp
     

    To get a particular view to take focus, call requestFocus().

    Touch Mode

    When a user is navigating a user interface via directional keys such as a D-pad, it is necessary to give focus to actionable items such as buttons so the user can see what will take input. If the device has touch capabilities, however, and the user begins interacting with the interface by touching it, it is no longer necessary to always highlight, or give focus to, a particular view. This motivates a mode for interaction named 'touch mode'.

    For a touch capable device, once the user touches the screen, the device will enter touch mode. From this point onward, only views for which isFocusableInTouchMode() is true will be focusable, such as text editing widgets. Other views that are touchable, like buttons, will not take focus when touched; they will only fire the on click listeners.

    Any time a user hits a directional key, such as a D-pad direction, the view device will exit touch mode, and find a view to take focus, so that the user may resume interacting with the user interface without touching the screen again.

    The touch mode state is maintained across Activitys. Call isInTouchMode() to see whether the device is currently in touch mode.

    Scrolling

    The framework provides basic support for views that wish to internally scroll their content. This includes keeping track of the X and Y scroll offset as well as mechanisms for drawing scrollbars. See scrollBy(int, int), scrollTo(int, int), and awakenScrollBars() for more details.

    Tags

    Unlike IDs, tags are not used to identify views. Tags are essentially an extra piece of information that can be associated with a view. They are most often used as a convenience to store data related to views in the views themselves rather than by putting them in a separate structure.

    Properties

    The View class exposes an ALPHA property, as well as several transform-related properties, such as TRANSLATION_X and TRANSLATION_Y. These properties are available both in the Property form as well as in similarly-named setter/getter methods (such as setAlpha(float) for ALPHA). These properties can be used to set persistent state associated with these rendering-related properties on the view. The properties and methods can also be used in conjunction with Animator-based animations, described more in the Animation section.

    Animation

    Starting with Android 3.0, the preferred way of animating views is to use the android.animation package APIs. These Animator-based classes change actual properties of the View object, such as alpha and translationX. This behavior is contrasted to that of the pre-3.0 Animation-based classes, which instead animate only how the view is drawn on the display. In particular, the ViewPropertyAnimator class makes animating these View properties particularly easy and efficient.

    Alternatively, you can use the pre-3.0 animation classes to animate how Views are rendered. You can attach an Animation object to a view using setAnimation(Animation) or startAnimation(Animation). The animation can alter the scale, rotation, translation and alpha of a view over time. If the animation is attached to a view that has children, the animation will affect the entire subtree rooted by that node. When an animation is started, the framework will take care of redrawing the appropriate views until the animation completes.

    Security

    Sometimes it is essential that an application be able to verify that an action is being performed with the full knowledge and consent of the user, such as granting a permission request, making a purchase or clicking on an advertisement. Unfortunately, a malicious application could try to spoof the user into performing these actions, unaware, by concealing the intended purpose of the view. As a remedy, the framework offers a touch filtering mechanism that can be used to improve the security of views that provide access to sensitive functionality.

    To enable touch filtering, call setFilterTouchesWhenObscured(boolean) or set the android:filterTouchesWhenObscured layout attribute to true. When enabled, the framework will discard touches that are received whenever the view's window is obscured by another visible window. As a result, the view will not receive touches whenever a toast, dialog or other window appears above the view's window.

    For more fine-grained control over security, consider overriding the onFilterTouchEventForSecurity(MotionEvent) method to implement your own security policy. See also MotionEvent.FLAG_WINDOW_IS_OBSCURED.

    See Also:
    ViewGroup
    • Field Detail

      • VIEW_LOG_TAG

        protected static final String VIEW_LOG_TAG
        The logging tag used by this class with android.util.Log.
        See Also:
        Constant Field Values
      • DEBUG_LAYOUT_PROPERTY

        public static final String DEBUG_LAYOUT_PROPERTY
        When set to true, apps will draw debugging information about their layouts.
        See Also:
        Constant Field Values
      • DRAWING_CACHE_QUALITY_LOW

        public static final int DRAWING_CACHE_QUALITY_LOW

        Enables low quality mode for the drawing cache.

        See Also:
        Constant Field Values
      • DRAWING_CACHE_QUALITY_HIGH

        public static final int DRAWING_CACHE_QUALITY_HIGH

        Enables high quality mode for the drawing cache.

        See Also:
        Constant Field Values
      • DRAWING_CACHE_QUALITY_AUTO

        public static final int DRAWING_CACHE_QUALITY_AUTO

        Enables automatic quality mode for the drawing cache.

        See Also:
        Constant Field Values
      • SCROLLBARS_INSIDE_OVERLAY

        public static final int SCROLLBARS_INSIDE_OVERLAY
        The scrollbar style to display the scrollbars inside the content area, without increasing the padding. The scrollbars will be overlaid with translucency on the view's content.
        See Also:
        Constant Field Values
      • SCROLLBARS_INSIDE_INSET

        public static final int SCROLLBARS_INSIDE_INSET
        The scrollbar style to display the scrollbars inside the padded area, increasing the padding of the view. The scrollbars will not overlap the content area of the view.
        See Also:
        Constant Field Values
      • SCROLLBARS_OUTSIDE_OVERLAY

        public static final int SCROLLBARS_OUTSIDE_OVERLAY
        The scrollbar style to display the scrollbars at the edge of the view, without increasing the padding. The scrollbars will be overlaid with translucency.
        See Also:
        Constant Field Values
      • SCROLLBARS_OUTSIDE_INSET

        public static final int SCROLLBARS_OUTSIDE_INSET
        The scrollbar style to display the scrollbars at the edge of the view, increasing the padding of the view. The scrollbars will only overlap the background, if any.
        See Also:
        Constant Field Values
      • SOUND_EFFECTS_ENABLED

        public static final int SOUND_EFFECTS_ENABLED
        View flag indicating whether this view should have sound effects enabled for events such as clicking and touching.
        See Also:
        Constant Field Values
      • HAPTIC_FEEDBACK_ENABLED

        public static final int HAPTIC_FEEDBACK_ENABLED
        View flag indicating whether this view should have haptic feedback enabled for events such as long presses.
        See Also:
        Constant Field Values
      • EMPTY_STATE_SET

        protected static final int[] EMPTY_STATE_SET
        Indicates the view has no states set. States are used with Drawable to change the drawing of the view depending on its state.
        See Also:
        Drawable, getDrawableState()
      • ENABLED_STATE_SET

        protected static final int[] ENABLED_STATE_SET
        Indicates the view is enabled. States are used with Drawable to change the drawing of the view depending on its state.
        See Also:
        Drawable, getDrawableState()
      • FOCUSED_STATE_SET

        protected static final int[] FOCUSED_STATE_SET
        Indicates the view is focused. States are used with Drawable to change the drawing of the view depending on its state.
        See Also:
        Drawable, getDrawableState()
      • SELECTED_STATE_SET

        protected static final int[] SELECTED_STATE_SET
        Indicates the view is selected. States are used with Drawable to change the drawing of the view depending on its state.
        See Also:
        Drawable, getDrawableState()
      • PRESSED_STATE_SET

        protected static final int[] PRESSED_STATE_SET
        Indicates the view is pressed. States are used with Drawable to change the drawing of the view depending on its state.
        See Also:
        Drawable, getDrawableState()
      • WINDOW_FOCUSED_STATE_SET

        protected static final int[] WINDOW_FOCUSED_STATE_SET
        Indicates the view's window has focus. States are used with Drawable to change the drawing of the view depending on its state.
        See Also:
        Drawable, getDrawableState()
      • ENABLED_FOCUSED_STATE_SET

        protected static final int[] ENABLED_FOCUSED_STATE_SET
        Indicates the view is enabled and has the focus.
        See Also:
        ENABLED_STATE_SET, FOCUSED_STATE_SET
      • ENABLED_SELECTED_STATE_SET

        protected static final int[] ENABLED_SELECTED_STATE_SET
        Indicates the view is enabled and selected.
        See Also:
        ENABLED_STATE_SET, SELECTED_STATE_SET
      • ENABLED_WINDOW_FOCUSED_STATE_SET

        protected static final int[] ENABLED_WINDOW_FOCUSED_STATE_SET
        Indicates the view is enabled and that its window has focus.
        See Also:
        ENABLED_STATE_SET, WINDOW_FOCUSED_STATE_SET
      • FOCUSED_SELECTED_STATE_SET

        protected static final int[] FOCUSED_SELECTED_STATE_SET
        Indicates the view is focused and selected.
        See Also:
        FOCUSED_STATE_SET, SELECTED_STATE_SET
      • FOCUSED_WINDOW_FOCUSED_STATE_SET

        protected static final int[] FOCUSED_WINDOW_FOCUSED_STATE_SET
        Indicates the view has the focus and that its window has the focus.
        See Also:
        FOCUSED_STATE_SET, WINDOW_FOCUSED_STATE_SET
      • SELECTED_WINDOW_FOCUSED_STATE_SET

        protected static final int[] SELECTED_WINDOW_FOCUSED_STATE_SET
        Indicates the view is selected and that its window has the focus.
        See Also:
        SELECTED_STATE_SET, WINDOW_FOCUSED_STATE_SET
      • PRESSED_WINDOW_FOCUSED_STATE_SET

        protected static final int[] PRESSED_WINDOW_FOCUSED_STATE_SET
        Indicates the view is pressed and its window has the focus.
        See Also:
        PRESSED_STATE_SET, WINDOW_FOCUSED_STATE_SET
      • PRESSED_SELECTED_STATE_SET

        protected static final int[] PRESSED_SELECTED_STATE_SET
        Indicates the view is pressed and selected.
        See Also:
        PRESSED_STATE_SET, SELECTED_STATE_SET
      • PRESSED_FOCUSED_STATE_SET

        protected static final int[] PRESSED_FOCUSED_STATE_SET
        Indicates the view is pressed and focused.
        See Also:
        PRESSED_STATE_SET, FOCUSED_STATE_SET
      • PRESSED_ENABLED_STATE_SET

        protected static final int[] PRESSED_ENABLED_STATE_SET
        Indicates the view is pressed and enabled.
        See Also:
        PRESSED_STATE_SET, ENABLED_STATE_SET
      • mCurrentAnimation

        protected Animation mCurrentAnimation
        The animation currently associated with this view.
      • LAYOUT_DIRECTION_LOCALE

        public static final int LAYOUT_DIRECTION_LOCALE
        Horizontal layout direction of this view is from deduced from the default language script for the locale. Use with setLayoutDirection(int).
        See Also:
        Constant Field Values
      • TEXT_DIRECTION_FIRST_STRONG

        public static final int TEXT_DIRECTION_FIRST_STRONG
        Text direction is using "first strong algorithm". The first strong directional character determines the paragraph direction. If there is no strong directional character, the paragraph direction is the view's resolved layout direction.
        See Also:
        Constant Field Values
      • TEXT_DIRECTION_ANY_RTL

        public static final int TEXT_DIRECTION_ANY_RTL
        Text direction is using "any-RTL" algorithm. The paragraph direction is RTL if it contains any strong RTL character, otherwise it is LTR if it contains any strong LTR characters. If there are neither, the paragraph direction is the view's resolved layout direction.
        See Also:
        Constant Field Values
      • TEXT_DIRECTION_LTR

        public static final int TEXT_DIRECTION_LTR
        Text direction is forced to LTR.
        See Also:
        Constant Field Values
      • TEXT_DIRECTION_RTL

        public static final int TEXT_DIRECTION_RTL
        Text direction is forced to RTL.
        See Also:
        Constant Field Values
      • TEXT_DIRECTION_LOCALE

        public static final int TEXT_DIRECTION_LOCALE
        Text direction is coming from the system Locale.
        See Also:
        Constant Field Values
      • TEXT_ALIGNMENT_GRAVITY

        public static final int TEXT_ALIGNMENT_GRAVITY
        Default for the root view. The gravity determines the text alignment, ALIGN_NORMAL, ALIGN_CENTER, or ALIGN_OPPOSITE, which are relative to each paragraph’s text direction. Use with setTextAlignment(int)
        See Also:
        Constant Field Values
      • TEXT_ALIGNMENT_VIEW_START

        public static final int TEXT_ALIGNMENT_VIEW_START
        Align to the start of the view, which is ALIGN_LEFT if the view’s resolved layoutDirection is LTR, and ALIGN_RIGHT otherwise. Use with setTextAlignment(int)
        See Also:
        Constant Field Values
      • TEXT_ALIGNMENT_VIEW_END

        public static final int TEXT_ALIGNMENT_VIEW_END
        Align to the end of the view, which is ALIGN_RIGHT if the view’s resolved layoutDirection is LTR, and ALIGN_LEFT otherwise. Use with setTextAlignment(int)
        See Also:
        Constant Field Values
      • IMPORTANT_FOR_ACCESSIBILITY_AUTO

        public static final int IMPORTANT_FOR_ACCESSIBILITY_AUTO
        Automatically determine whether a view is important for accessibility.
        See Also:
        Constant Field Values
      • IMPORTANT_FOR_ACCESSIBILITY_YES

        public static final int IMPORTANT_FOR_ACCESSIBILITY_YES
        The view is important for accessibility.
        See Also:
        Constant Field Values
      • IMPORTANT_FOR_ACCESSIBILITY_NO

        public static final int IMPORTANT_FOR_ACCESSIBILITY_NO
        The view is not important for accessibility.
        See Also:
        Constant Field Values
      • SYSTEM_UI_FLAG_LOW_PROFILE

        public static final int SYSTEM_UI_FLAG_LOW_PROFILE
        Flag for setSystemUiVisibility(int): View has requested the system UI to enter an unobtrusive "low profile" mode.

        This is for use in games, book readers, video players, or any other "immersive" application where the usual system chrome is deemed too distracting.

        In low profile mode, the status bar and/or navigation icons may dim.

        See Also:
        setSystemUiVisibility(int), Constant Field Values
      • SYSTEM_UI_FLAG_HIDE_NAVIGATION

        public static final int SYSTEM_UI_FLAG_HIDE_NAVIGATION
        Flag for setSystemUiVisibility(int): View has requested that the system navigation be temporarily hidden.

        This is an even less obtrusive state than that called for by SYSTEM_UI_FLAG_LOW_PROFILE; on devices that draw essential navigation controls (Home, Back, and the like) on screen, SYSTEM_UI_FLAG_HIDE_NAVIGATION will cause those to disappear. This is useful (in conjunction with the FLAG_FULLSCREEN and FLAG_LAYOUT_IN_SCREEN window flags) for displaying content using every last pixel on the display.

        There is a limitation: because navigation controls are so important, the least user interaction will cause them to reappear immediately. When this happens, both this flag and SYSTEM_UI_FLAG_FULLSCREEN will be cleared automatically, so that both elements reappear at the same time.

        See Also:
        setSystemUiVisibility(int), Constant Field Values
      • SYSTEM_UI_FLAG_FULLSCREEN

        public static final int SYSTEM_UI_FLAG_FULLSCREEN
        Flag for setSystemUiVisibility(int): View has requested to go into the normal fullscreen mode so that its content can take over the screen while still allowing the user to interact with the application.

        This has the same visual effect as WindowManager.LayoutParams.FLAG_FULLSCREEN, meaning that non-critical screen decorations (such as the status bar) will be hidden while the user is in the View's window, focusing the experience on that content. Unlike the window flag, if you are using ActionBar in overlay mode with Window.FEATURE_ACTION_BAR_OVERLAY, then enabling this flag will also hide the action bar.

        This approach to going fullscreen is best used over the window flag when it is a transient state -- that is, the application does this at certain points in its user interaction where it wants to allow the user to focus on content, but not as a continuous state. For situations where the application would like to simply stay full screen the entire time (such as a game that wants to take over the screen), the window flag is usually a better approach. The state set here will be removed by the system in various situations (such as the user moving to another application) like the other system UI states.

        When using this flag, the application should provide some easy facility for the user to go out of it. A common example would be in an e-book reader, where tapping on the screen brings back whatever screen and UI decorations that had been hidden while the user was immersed in reading the book.

        See Also:
        setSystemUiVisibility(int), Constant Field Values
      • SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION

        public static final int SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
        Flag for setSystemUiVisibility(int): View would like its window to be layed out as if it has requested SYSTEM_UI_FLAG_HIDE_NAVIGATION, even if it currently hasn't. This allows it to avoid artifacts when switching in and out of that mode, at the expense that some of its user interface may be covered by screen decorations when they are shown. You can perform layout of your inner UI elements to account for the navagation system UI through the fitSystemWindows(Rect) method.
        See Also:
        Constant Field Values
      • SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

        public static final int SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
        Flag for setSystemUiVisibility(int): View would like its window to be layed out as if it has requested SYSTEM_UI_FLAG_FULLSCREEN, even if it currently hasn't. This allows it to avoid artifacts when switching in and out of that mode, at the expense that some of its user interface may be covered by screen decorations when they are shown. You can perform layout of your inner UI elements to account for non-fullscreen system UI through the fitSystemWindows(Rect) method.
        See Also:
        Constant Field Values
      • STATUS_BAR_DISABLE_EXPAND

        public static final int STATUS_BAR_DISABLE_EXPAND
        See Also:
        Constant Field Values
      • STATUS_BAR_DISABLE_NOTIFICATION_ICONS

        public static final int STATUS_BAR_DISABLE_NOTIFICATION_ICONS
        See Also:
        Constant Field Values
      • STATUS_BAR_DISABLE_NOTIFICATION_ALERTS

        public static final int STATUS_BAR_DISABLE_NOTIFICATION_ALERTS
        See Also:
        Constant Field Values
      • STATUS_BAR_DISABLE_NOTIFICATION_TICKER

        public static final int STATUS_BAR_DISABLE_NOTIFICATION_TICKER
        See Also:
        Constant Field Values
      • STATUS_BAR_DISABLE_SYSTEM_INFO

        public static final int STATUS_BAR_DISABLE_SYSTEM_INFO
        See Also:
        Constant Field Values
      • STATUS_BAR_DISABLE_CLOCK

        public static final int STATUS_BAR_DISABLE_CLOCK
        See Also:
        Constant Field Values
      • STATUS_BAR_DISABLE_RECENT

        public static final int STATUS_BAR_DISABLE_RECENT
        See Also:
        Constant Field Values
      • STATUS_BAR_DISABLE_SEARCH

        public static final int STATUS_BAR_DISABLE_SEARCH
        See Also:
        Constant Field Values
      • PUBLIC_STATUS_BAR_VISIBILITY_MASK

        public static final int PUBLIC_STATUS_BAR_VISIBILITY_MASK
        See Also:
        Constant Field Values
      • SYSTEM_UI_CLEARABLE_FLAGS

        public static final int SYSTEM_UI_CLEARABLE_FLAGS
        These are the system UI flags that can be cleared by events outside of an application. Currently this is just the ability to tap on the screen while hiding the navigation bar to have it return.
        See Also:
        Constant Field Values
      • SYSTEM_UI_LAYOUT_FLAGS

        public static final int SYSTEM_UI_LAYOUT_FLAGS
        Flags that can impact the layout in relation to system UI.
        See Also:
        Constant Field Values
      • FIND_VIEWS_WITH_ACCESSIBILITY_NODE_PROVIDERS

        public static final int FIND_VIEWS_WITH_ACCESSIBILITY_NODE_PROVIDERS
        Find views that contain AccessibilityNodeProvider. Such a View is a root of virtual view hierarchy and may contain the searched text. If this flag is set Views with providers are automatically added and it is a responsibility of the client to call the APIs of the provider to determine whether the virtual tree rooted at this View contains the text, i.e. getting the list of AccessibilityNodeInfos represeting the virtual views with this text.
        See Also:
        findViewsWithText(ArrayList, CharSequence, int), Constant Field Values
      • mLayoutParams

        protected ViewGroup.LayoutParams mLayoutParams
        The layout parameters associated with this view and used by the parent ViewGroup to determine how this view should be laid out.
      • mLeft

        protected int mLeft
        The distance in pixels from the left edge of this view's parent to the left edge of this view.
      • mRight

        protected int mRight
        The distance in pixels from the left edge of this view's parent to the right edge of this view.
      • mTop

        protected int mTop
        The distance in pixels from the top edge of this view's parent to the top edge of this view.
      • mBottom

        protected int mBottom
        The distance in pixels from the top edge of this view's parent to the bottom edge of this view.
      • mScrollX

        protected int mScrollX
        The offset, in pixels, by which the content of this view is scrolled horizontally.
      • mScrollY

        protected int mScrollY
        The offset, in pixels, by which the content of this view is scrolled vertically.
      • mPaddingLeft

        protected int mPaddingLeft
        The left padding in pixels, that is the distance in pixels between the left edge of this view and the left edge of its content.
      • mPaddingRight

        protected int mPaddingRight
        The right padding in pixels, that is the distance in pixels between the right edge of this view and the right edge of its content.
      • mPaddingTop

        protected int mPaddingTop
        The top padding in pixels, that is the distance in pixels between the top edge of this view and the top edge of its content.
      • mPaddingBottom

        protected int mPaddingBottom
        The bottom padding in pixels, that is the distance in pixels between the bottom edge of this view and the bottom edge of its content.
      • mUserPaddingRight

        protected int mUserPaddingRight
        Cache the paddingRight set by the user to append to the scrollbar's size.
      • mUserPaddingBottom

        protected int mUserPaddingBottom
        Cache the paddingBottom set by the user to append to the scrollbar's size.
      • mUserPaddingLeft

        protected int mUserPaddingLeft
        Cache the paddingLeft set by the user to append to the scrollbar's size.
      • mContext

        protected Context mContext
        The application environment this view lives in. This field should be made private, so it is hidden from the SDK.
      • mCachingFailed

        public boolean mCachingFailed
        Set to true when drawing cache is enabled and cannot be created.
      • SCROLLBAR_POSITION_DEFAULT

        public static final int SCROLLBAR_POSITION_DEFAULT
        Position the scroll bar at the default position as determined by the system.
        See Also:
        Constant Field Values
      • SCROLLBAR_POSITION_LEFT

        public static final int SCROLLBAR_POSITION_LEFT
        Position the scroll bar along the left edge.
        See Also:
        Constant Field Values
      • SCROLLBAR_POSITION_RIGHT

        public static final int SCROLLBAR_POSITION_RIGHT
        Position the scroll bar along the right edge.
        See Also:
        Constant Field Values
      • LAYER_TYPE_SOFTWARE

        public static final int LAYER_TYPE_SOFTWARE

        Indicates that the view has a software layer. A software layer is backed by a bitmap and causes the view to be rendered using Android's software rendering pipeline, even if hardware acceleration is enabled.

        Software layers have various usages:

        When the application is not using hardware acceleration, a software layer is useful to apply a specific color filter and/or blending mode and/or translucency to a view and all its children.

        When the application is using hardware acceleration, a software layer is useful to render drawing primitives not supported by the hardware accelerated pipeline. It can also be used to cache a complex view tree into a texture and reduce the complexity of drawing operations. For instance, when animating a complex view tree with a translation, a software layer can be used to render the view tree only once.

        Software layers should be avoided when the affected view tree updates often. Every update will require to re-render the software layer, which can potentially be slow (particularly when hardware acceleration is turned on since the layer will have to be uploaded into a hardware texture after every update.)

        See Also:
        getLayerType(), setLayerType(int, android.graphics.Paint), LAYER_TYPE_NONE, LAYER_TYPE_HARDWARE, Constant Field Values
      • LAYER_TYPE_HARDWARE

        public static final int LAYER_TYPE_HARDWARE

        Indicates that the view has a hardware layer. A hardware layer is backed by a hardware specific texture (generally Frame Buffer Objects or FBO on OpenGL hardware) and causes the view to be rendered using Android's hardware rendering pipeline, but only if hardware acceleration is turned on for the view hierarchy. When hardware acceleration is turned off, hardware layers behave exactly as software layers.

        A hardware layer is useful to apply a specific color filter and/or blending mode and/or translucency to a view and all its children.

        A hardware layer can be used to cache a complex view tree into a texture and reduce the complexity of drawing operations. For instance, when animating a complex view tree with a translation, a hardware layer can be used to render the view tree only once.

        A hardware layer can also be used to increase the rendering quality when rotation transformations are applied on a view. It can also be used to prevent potential clipping issues when applying 3D transforms on a view.

        See Also:
        getLayerType(), setLayerType(int, android.graphics.Paint), LAYER_TYPE_NONE, LAYER_TYPE_SOFTWARE, Constant Field Values
      • mInputEventConsistencyVerifier

        protected final InputEventConsistencyVerifier mInputEventConsistencyVerifier
        Consistency verifier for debugging purposes.
    • Constructor Detail

      • View

        public View(Context context)
        Simple constructor to use when creating a view from code.
        Parameters:
        context - The Context the view is running in, through which it can access the current theme, resources, etc.
      • View

        public View(Context context,
            AttributeSet attrs)
        Constructor that is called when inflating a view from XML. This is called when a view is being constructed from an XML file, supplying attributes that were specified in the XML file. This version uses a default style of 0, so the only attribute values applied are those in the Context's Theme and the given AttributeSet.

        The method onFinishInflate() will be called after all children have been added.

        Parameters:
        context - The Context the view is running in, through which it can access the current theme, resources, etc.
        attrs - The attributes of the XML tag that is inflating the view.
        See Also:
        View(Context, AttributeSet, int)
      • View

        public View(Context context,
            AttributeSet attrs,
            int defStyle)
        Perform inflation from XML and apply a class-specific base style. This constructor of View allows subclasses to use their own base style when they are inflating. For example, a Button class's constructor would call this version of the super class constructor and supply R.attr.buttonStyle for defStyle; this allows the theme's button style to modify all of the base view attributes (in particular its background) as well as the Button class's attributes.
        Parameters:
        context - The Context the view is running in, through which it can access the current theme, resources, etc.
        attrs - The attributes of the XML tag that is inflating the view.
        defStyle - The default style to apply to this view. If 0, no style will be applied (beyond what is included in the theme). This may either be an attribute resource, whose value will be retrieved from the current theme, or an explicit style resource.
        See Also:
        View(Context, AttributeSet)
    • Method Detail

      • toString

        public String toString()
        Description copied from class: Object
        Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:
           getClass().getName() + '@' + Integer.toHexString(hashCode())

        See Writing a useful toString method if you intend implementing your own toString method.

        Overrides:
        toString in class Object
        Returns:
        a printable representation of this object.
      • initializeFadingEdge

        protected void initializeFadingEdge(TypedArray a)

        Initializes the fading edges from a given set of styled attributes. This method should be called by subclasses that need fading edges and when an instance of these subclasses is created programmatically rather than being inflated from XML. This method is automatically called when the XML is inflated.

        Parameters:
        a - the styled attributes set to initialize the fading edges from
      • getVerticalFadingEdgeLength

        public int getVerticalFadingEdgeLength()
        Returns the size of the vertical faded edges used to indicate that more content in this view is visible.
        Returns:
        The size in pixels of the vertical faded edge or 0 if vertical faded edges are not enabled for this view.
      • setFadingEdgeLength

        public void setFadingEdgeLength(int length)
        Set the size of the faded edge used to indicate that more content in this view is available. Will not change whether the fading edge is enabled; use setVerticalFadingEdgeEnabled(boolean) or setHorizontalFadingEdgeEnabled(boolean) to enable the fading edge for the vertical or horizontal fading edges.
        Parameters:
        length - The size in pixels of the faded edge used to indicate that more content in this view is visible.
      • getHorizontalFadingEdgeLength

        public int getHorizontalFadingEdgeLength()
        Returns the size of the horizontal faded edges used to indicate that more content in this view is visible.
        Returns:
        The size in pixels of the horizontal faded edge or 0 if horizontal faded edges are not enabled for this view.
      • getVerticalScrollbarWidth

        public int getVerticalScrollbarWidth()
        Returns the width of the vertical scrollbar.
        Returns:
        The width in pixels of the vertical scrollbar or 0 if there is no vertical scrollbar.
      • getHorizontalScrollbarHeight

        protected int getHorizontalScrollbarHeight()
        Returns the height of the horizontal scrollbar.
        Returns:
        The height in pixels of the horizontal scrollbar or 0 if there is no horizontal scrollbar.
      • initializeScrollbars

        protected void initializeScrollbars(TypedArray a)

        Initializes the scrollbars from a given set of styled attributes. This method should be called by subclasses that need scrollbars and when an instance of these subclasses is created programmatically rather than being inflated from XML. This method is automatically called when the XML is inflated.

        Parameters:
        a - the styled attributes set to initialize the scrollbars from
      • getVerticalScrollbarPosition

        public int getVerticalScrollbarPosition()
        Returns:
        The position where the vertical scroll bar will show, if applicable.
        See Also:
        setVerticalScrollbarPosition(int)
      • setOnFocusChangeListener

        public void setOnFocusChangeListener(View.OnFocusChangeListener l)
        Register a callback to be invoked when focus of this view changed.
        Parameters:
        l - The callback that will run.
      • addOnLayoutChangeListener

        public void addOnLayoutChangeListener(View.OnLayoutChangeListener listener)
        Add a listener that will be called when the bounds of the view change due to layout processing.
        Parameters:
        listener - The listener that will be called when layout bounds change.
      • removeOnLayoutChangeListener

        public void removeOnLayoutChangeListener(View.OnLayoutChangeListener listener)
        Remove a listener for layout changes.
        Parameters:
        listener - The listener for layout bounds change.
      • getOnFocusChangeListener

        public View.OnFocusChangeListener getOnFocusChangeListener()
        Returns the focus-change callback registered for this view.
        Returns:
        The callback, or null if one is not registered.
      • setOnClickListener

        public void setOnClickListener(View.OnClickListener l)
        Register a callback to be invoked when this view is clicked. If this view is not clickable, it becomes clickable.
        Parameters:
        l - The callback that will run
        See Also:
        setClickable(boolean)
      • hasOnClickListeners

        public boolean hasOnClickListeners()
        Return whether this view has an attached OnClickListener. Returns true if there is a listener, false if there is none.
      • setOnLongClickListener

        public void setOnLongClickListener(View.OnLongClickListener l)
        Register a callback to be invoked when this view is clicked and held. If this view is not long clickable, it becomes long clickable.
        Parameters:
        l - The callback that will run
        See Also:
        setLongClickable(boolean)
      • setOnCreateContextMenuListener

        public void setOnCreateContextMenuListener(View.OnCreateContextMenuListener l)
        Register a callback to be invoked when the context menu for this view is being built. If this view is not long clickable, it becomes long clickable.
        Parameters:
        l - The callback that will run
      • performClick

        public boolean performClick()
        Call this view's OnClickListener, if it is defined. Performs all normal actions associated with clicking: reporting accessibility event, playing a sound, etc.
        Returns:
        True there was an assigned OnClickListener that was called, false otherwise is returned.
      • callOnClick

        public boolean callOnClick()
        Directly call any attached OnClickListener. Unlike performClick(), this only calls the listener, and does not do any associated clicking actions like reporting an accessibility event.
        Returns:
        True there was an assigned OnClickListener that was called, false otherwise is returned.
      • performLongClick

        public boolean performLongClick()
        Call this view's OnLongClickListener, if it is defined. Invokes the context menu if the OnLongClickListener did not consume the event.
        Returns:
        True if one of the above receivers consumed the event, false otherwise.
      • performButtonActionOnTouchDown

        protected boolean performButtonActionOnTouchDown(MotionEvent event)
        Performs button-related actions during a touch down event.
        Parameters:
        event - The event.
        Returns:
        True if the down was consumed.
      • showContextMenu

        public boolean showContextMenu()
        Bring up the context menu for this view.
        Returns:
        Whether a context menu was displayed.
      • showContextMenu

        public boolean showContextMenu(float x,
                              float y,
                              int metaState)
        Bring up the context menu for this view, referring to the item under the specified point.
        Parameters:
        x - The referenced x coordinate.
        y - The referenced y coordinate.
        metaState - The keyboard modifiers that were pressed.
        Returns:
        Whether a context menu was displayed.
      • startActionMode

        public ActionMode startActionMode(ActionMode.Callback callback)
        Start an action mode.
        Parameters:
        callback - Callback that will control the lifecycle of the action mode
        Returns:
        The new action mode if it is started, null otherwise
        See Also:
        ActionMode
      • setOnKeyListener

        public void setOnKeyListener(View.OnKeyListener l)
        Register a callback to be invoked when a hardware key is pressed in this view. Key presses in software input methods will generally not trigger the methods of this listener.
        Parameters:
        l - the key listener to attach to this view
      • setOnTouchListener

        public void setOnTouchListener(View.OnTouchListener l)
        Register a callback to be invoked when a touch event is sent to this view.
        Parameters:
        l - the touch listener to attach to this view
      • setOnGenericMotionListener

        public void setOnGenericMotionListener(View.OnGenericMotionListener l)
        Register a callback to be invoked when a generic motion event is sent to this view.
        Parameters:
        l - the generic motion listener to attach to this view
      • setOnHoverListener

        public void setOnHoverListener(View.OnHoverListener l)
        Register a callback to be invoked when a hover event is sent to this view.
        Parameters:
        l - the hover listener to attach to this view
      • requestRectangleOnScreen

        public boolean requestRectangleOnScreen(Rect rectangle)
        Request that a rectangle of this view be visible on the screen, scrolling if necessary just enough.

        A View should call this if it maintains some notion of which part of its content is interesting. For example, a text editing view should call this when its cursor moves.

        Parameters:
        rectangle - The rectangle.
        Returns:
        Whether any parent scrolled.
      • requestRectangleOnScreen

        public boolean requestRectangleOnScreen(Rect rectangle,
                                       boolean immediate)
        Request that a rectangle of this view be visible on the screen, scrolling if necessary just enough.

        A View should call this if it maintains some notion of which part of its content is interesting. For example, a text editing view should call this when its cursor moves.

        When immediate is set to true, scrolling will not be animated.

        Parameters:
        rectangle - The rectangle.
        immediate - True to forbid animated scrolling, false otherwise
        Returns:
        Whether any parent scrolled.
      • clearFocus

        public void clearFocus()
        Called when this view wants to give up focus. If focus is cleared onFocusChanged(boolean, int, android.graphics.Rect) is called.

        Note: When a View clears focus the framework is trying to give focus to the first focusable View from the top. Hence, if this View is the first from the top that can take focus, then all callbacks related to clearing focus will be invoked after wich the framework will give focus to this view.

      • hasFocus

        public boolean hasFocus()
        Returns true if this view has focus iteself, or is the ancestor of the view that has focus.
        Returns:
        True if this view has or contains focus, false otherwise.
      • hasFocusable

        public boolean hasFocusable()
        Returns true if this view is focusable or if it contains a reachable View for which hasFocusable() returns true. A "reachable hasFocusable()" is a View whose parents do not block descendants focus. Only VISIBLE views are considered focusable.
        Returns:
        True if the view is focusable or if the view contains a focusable View, false otherwise.
        See Also:
        ViewGroup.FOCUS_BLOCK_DESCENDANTS
      • onFocusChanged

        protected void onFocusChanged(boolean gainFocus,
                          int direction,
                          Rect previouslyFocusedRect)
        Called by the view system when the focus state of this view changes. When the focus change event is caused by directional navigation, direction and previouslyFocusedRect provide insight into where the focus is coming from. When overriding, be sure to call up through to the super class so that the standard focus handling will occur.
        Parameters:
        gainFocus - True if the View has focus; false otherwise.
        direction - The direction focus has moved when requestFocus() is called to give this view focus. Values are FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_FORWARD, or FOCUS_BACKWARD. It may not always apply, in which case use the default.
        previouslyFocusedRect - The rectangle, in this view's coordinate system, of the previously focused view. If applicable, this will be passed in as finer grained information about where the focus is coming from (in addition to direction). Will be null otherwise.
      • announceForAccessibility

        public void announceForAccessibility(CharSequence text)
        Convenience method for sending a AccessibilityEvent.TYPE_ANNOUNCEMENT AccessibilityEvent to make an announcement which is related to some sort of a context change for which none of the events representing UI transitions is a good fit. For example, announcing a new page in a book. If accessibility is not enabled this method does nothing.
        Parameters:
        text - The announcement text.
      • isVisibleToUser

        protected boolean isVisibleToUser()
        Computes whether this view is visible to the user. Such a view is attached, visible, all its predecessors are visible, it is not clipped entirely by its predecessors, and has an alpha greater than zero.
        Returns:
        Whether the view is visible on the screen.
      • isVisibleToUser

        protected boolean isVisibleToUser(Rect boundInView)
        Computes whether the given portion of this view is visible to the user. Such a view is attached, visible, all its predecessors are visible, has an alpha greater than zero, and the specified portion is not clipped entirely by its predecessors.
        Parameters:
        boundInView - the portion of the view to test; coordinates should be relative; may be null, and the entire view will be tested in this case. When true is returned by the function, the actual visible region will be stored in this parameter; that is, if boundInView is fully contained within the view, no modification will be made, otherwise regions outside of the visible area of the view will be clipped.
        Returns:
        Whether the specified portion of the view is visible on the screen.
      • setAccessibilityDelegate

        public void setAccessibilityDelegate(View.AccessibilityDelegate delegate)
        Sets a delegate for implementing accessibility support via composition as opposed to inheritance. The delegate's primary use is for implementing backwards compatible widgets. For more details see View.AccessibilityDelegate.
        Parameters:
        delegate - The delegate instance.
        See Also:
        View.AccessibilityDelegate
      • getAccessibilityViewId

        public int getAccessibilityViewId()
        Gets the unique identifier of this view on the screen for accessibility purposes. If this View is not attached to any window, -1 is returned.
        Returns:
        The view accessibility id.
      • getAccessibilityWindowId

        public int getAccessibilityWindowId()
        Gets the unique identifier of the window in which this View reseides.
        Returns:
        The window accessibility id.
      • getContentDescription

        public CharSequence getContentDescription()
        Gets the View description. It briefly describes the view and is primarily used for accessibility support. Set this property to enable better accessibility support for your application. This is especially true for views that do not have textual representation (For example, ImageButton).
        Returns:
        The content description.
      • setContentDescription

        public void setContentDescription(CharSequence contentDescription)
        Sets the View description. It briefly describes the view and is primarily used for accessibility support. Set this property to enable better accessibility support for your application. This is especially true for views that do not have textual representation (For example, ImageButton).
        Parameters:
        contentDescription - The content description.
      • getLabelFor

        public int getLabelFor()
        Gets the id of a view for which this view serves as a label for accessibility purposes.
        Returns:
        The labeled view id.
      • setLabelFor

        public void setLabelFor(int id)
        Sets the id of a view for which this view serves as a label for accessibility purposes.
        Parameters:
        id - The labeled view id.
      • onFocusLost

        protected void onFocusLost()
        Invoked whenever this view loses focus, either by losing window focus or by losing focus within its window. This method can be used to clear any state tied to the focus. For instance, if a button is held pressed with the trackball and the window loses focus, this method can be used to cancel the press. Subclasses of View overriding this method should always call super.onFocusLost().
        See Also:
        onFocusChanged(boolean, int, android.graphics.Rect), onWindowFocusChanged(boolean)
      • isFocused

        public boolean isFocused()
        Returns true if this view has focus
        Returns:
        True if this view has focus, false otherwise.
      • findFocus

        public View findFocus()
        Find the view in the hierarchy rooted at this view that currently has focus.
        Returns:
        The view that currently has focus, or null if no focused view can be found.
      • isScrollContainer

        public boolean isScrollContainer()
        Indicates whether this view is one of the set of scrollable containers in its window.
        Returns:
        whether this view is one of the set of scrollable containers in its window
      • setScrollContainer

        public void setScrollContainer(boolean isScrollContainer)
        Change whether this view is one of the set of scrollable containers in its window. This will be used to determine whether the window can resize or must pan when a soft input area is open -- scrollable containers allow the window to use resize mode since the container will appropriately shrink.
      • setKeepScreenOn

        public void setKeepScreenOn(boolean keepScreenOn)
        Controls whether the screen should remain on, modifying the value of KEEP_SCREEN_ON.
        Parameters:
        keepScreenOn - Supply true to set KEEP_SCREEN_ON.
        See Also:
        getKeepScreenOn()
      • getNextFocusLeftId

        public int getNextFocusLeftId()
        Gets the id of the view to use when the next focus is FOCUS_LEFT.
        Returns:
        The next focus ID, or NO_ID if the framework should decide automatically.
      • setNextFocusLeftId

        public void setNextFocusLeftId(int nextFocusLeftId)
        Sets the id of the view to use when the next focus is FOCUS_LEFT.
        Parameters:
        nextFocusLeftId - The next focus ID, or NO_ID if the framework should decide automatically.
      • getNextFocusRightId

        public int getNextFocusRightId()
        Gets the id of the view to use when the next focus is FOCUS_RIGHT.
        Returns:
        The next focus ID, or NO_ID if the framework should decide automatically.
      • setNextFocusRightId

        public void setNextFocusRightId(int nextFocusRightId)
        Sets the id of the view to use when the next focus is FOCUS_RIGHT.
        Parameters:
        nextFocusRightId - The next focus ID, or NO_ID if the framework should decide automatically.
      • getNextFocusUpId

        public int getNextFocusUpId()
        Gets the id of the view to use when the next focus is FOCUS_UP.
        Returns:
        The next focus ID, or NO_ID if the framework should decide automatically.
      • setNextFocusUpId

        public void setNextFocusUpId(int nextFocusUpId)
        Sets the id of the view to use when the next focus is FOCUS_UP.
        Parameters:
        nextFocusUpId - The next focus ID, or NO_ID if the framework should decide automatically.
      • getNextFocusDownId

        public int getNextFocusDownId()
        Gets the id of the view to use when the next focus is FOCUS_DOWN.
        Returns:
        The next focus ID, or NO_ID if the framework should decide automatically.
      • setNextFocusDownId

        public void setNextFocusDownId(int nextFocusDownId)
        Sets the id of the view to use when the next focus is FOCUS_DOWN.
        Parameters:
        nextFocusDownId - The next focus ID, or NO_ID if the framework should decide automatically.
      • getNextFocusForwardId

        public int getNextFocusForwardId()
        Gets the id of the view to use when the next focus is FOCUS_FORWARD.
        Returns:
        The next focus ID, or NO_ID if the framework should decide automatically.
      • setNextFocusForwardId

        public void setNextFocusForwardId(int nextFocusForwardId)
        Sets the id of the view to use when the next focus is FOCUS_FORWARD.
        Parameters:
        nextFocusForwardId - The next focus ID, or NO_ID if the framework should decide automatically.
      • isShown

        public boolean isShown()
        Returns the visibility of this view and all of its ancestors
        Returns:
        True if this view and all of its ancestors are VISIBLE
      • fitSystemWindows

        protected boolean fitSystemWindows(Rect insets)
        Called by the view hierarchy when the content insets for a window have changed, to allow it to adjust its content to fit within those windows. The content insets tell you the space that the status bar, input method, and other system windows infringe on the application's window.

        You do not normally need to deal with this function, since the default window decoration given to applications takes care of applying it to the content of the window. If you use SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION this will not be the case, and your content can be placed under those system elements. You can then use this method within your view hierarchy if you have parts of your UI which you would like to ensure are not being covered.

        The default implementation of this method simply applies the content inset's to the view's padding, consuming that content (modifying the insets to be 0), and returning true. This behavior is off by default, but can be enabled through setFitsSystemWindows(boolean).

        This function's traversal down the hierarchy is depth-first. The same content insets object is propagated down the hierarchy, so any changes made to it will be seen by all following views (including potentially ones above in the hierarchy since this is a depth-first traversal). The first view that returns true will abort the entire traversal.

        The default implementation works well for a situation where it is used with a container that covers the entire window, allowing it to apply the appropriate insets to its content on all edges. If you need a more complicated layout (such as two different views fitting system windows, one on the top of the window, and one on the bottom), you can override the method and handle the insets however you would like. Note that the insets provided by the framework are always relative to the far edges of the window, not accounting for the location of the called view within that window. (In fact when this method is called you do not yet know where the layout will place the view, as it is done before layout happens.)

        Note: unlike many View methods, there is no dispatch phase to this call. If you are overriding it in a ViewGroup and want to allow the call to continue to your children, you must be sure to call the super implementation.

        Here is a sample layout that makes use of fitting system windows to have controls for a video view placed inside of the window decorations that it hides and shows. This can be used with code like the second sample (video player) shown in setSystemUiVisibility(int).

        Parameters:
        insets - Current content insets of the window. Prior to Build.VERSION_CODES.JELLY_BEAN you must not modify the insets or else you and Android will be unhappy.
        Returns:
        Return true if this view applied the insets and it should not continue propagating further down the hierarchy, false otherwise.
        See Also:
        getFitsSystemWindows(), setFitsSystemWindows(boolean), setSystemUiVisibility(int)
      • setFitsSystemWindows

        public void setFitsSystemWindows(boolean fitSystemWindows)
        Sets whether or not this view should account for system screen decorations such as the status bar and inset its content; that is, controlling whether the default implementation of fitSystemWindows(Rect) will be executed. See that method for more details.

        Note that if you are providing your own implementation of fitSystemWindows(Rect), then there is no need to set this flag to true -- your implementation will be overriding the default implementation that checks this flag.

        Parameters:
        fitSystemWindows - If true, then the default implementation of fitSystemWindows(Rect) will be executed.
        See Also:
        getFitsSystemWindows(), fitSystemWindows(Rect), setSystemUiVisibility(int)
      • getFitsSystemWindows

        public boolean getFitsSystemWindows()
        Check for state of #setFitsSystemWindows(boolean). If this method returns true, the default implementation of {@link #fitSystemWindows(Rect)} will be executed.
        Returns:
        Returns true if the default implementation of fitSystemWindows(Rect) will be executed.
        See Also:
        #setFitsSystemWindows(), fitSystemWindows(Rect), setSystemUiVisibility(int)
      • fitsSystemWindows

        public boolean fitsSystemWindows()
      • requestFitSystemWindows

        public void requestFitSystemWindows()
        Ask that a new dispatch of fitSystemWindows(Rect) be performed.
      • makeOptionalFitsSystemWindows

        public void makeOptionalFitsSystemWindows()
        For use by PhoneWindow to make its own system window fitting optional.
      • getVisibility

        public int getVisibility()
        Returns the visibility status for this view.
        Returns:
        One of VISIBLE, INVISIBLE, or GONE.
      • setVisibility

        public void setVisibility(int visibility)
        Set the enabled state of this view.
        Parameters:
        visibility - One of VISIBLE, INVISIBLE, or GONE.
      • isEnabled

        public boolean isEnabled()
        Returns the enabled status for this view. The interpretation of the enabled state varies by subclass.
        Returns:
        True if this view is enabled, false otherwise.
      • setEnabled

        public void setEnabled(boolean enabled)
        Set the enabled state of this view. The interpretation of the enabled state varies by subclass.
        Parameters:
        enabled - True if this view is enabled, false otherwise.
      • setFocusable

        public void setFocusable(boolean focusable)
        Set whether this view can receive the focus. Setting this to false will also ensure that this view is not focusable in touch mode.
        Parameters:
        focusable - If true, this view can receive the focus.
        See Also:
        setFocusableInTouchMode(boolean)
      • setFocusableInTouchMode

        public void setFocusableInTouchMode(boolean focusableInTouchMode)
        Set whether this view can receive focus while in touch mode. Setting this to true will also ensure that this view is focusable.
        Parameters:
        focusableInTouchMode - If true, this view can receive the focus while in touch mode.
        See Also:
        setFocusable(boolean)
      • setSoundEffectsEnabled

        public void setSoundEffectsEnabled(boolean soundEffectsEnabled)
        Set whether this view should have sound effects enabled for events such as clicking and touching.

        You may wish to disable sound effects for a view if you already play sounds, for instance, a dial key that plays dtmf tones.

        Parameters:
        soundEffectsEnabled - whether sound effects are enabled for this view.
        See Also:
        isSoundEffectsEnabled(), playSoundEffect(int)
      • setHapticFeedbackEnabled

        public void setHapticFeedbackEnabled(boolean hapticFeedbackEnabled)
        Set whether this view should have haptic feedback for events such as long presses.

        You may wish to disable haptic feedback if your view already controls its own haptic feedback.

        Parameters:
        hapticFeedbackEnabled - whether haptic feedback enabled for this view.
        See Also:
        isHapticFeedbackEnabled(), performHapticFeedback(int)
      • setLayoutDirection

        public void setLayoutDirection(int layoutDirection)
        Set the layout direction for this view. This will propagate a reset of layout direction resolution to the view's children and resolve layout direction for this view.
        Parameters:
        layoutDirection - the layout direction to set. Should be one of: LAYOUT_DIRECTION_LTR, LAYOUT_DIRECTION_RTL, LAYOUT_DIRECTION_INHERIT, LAYOUT_DIRECTION_LOCALE. Resolution will be done if the value is set to LAYOUT_DIRECTION_INHERIT. The resolution proceeds up the parent chain of the view to get the value. If there is no parent, then it will return the default LAYOUT_DIRECTION_LTR.
      • isLayoutRtl

        public boolean isLayoutRtl()
        Indicates whether or not this view's layout is right-to-left. This is resolved from layout attribute and/or the inherited value from the parent
        Returns:
        true if the layout is right-to-left.
      • hasTransientState

        public boolean hasTransientState()
        Indicates whether the view is currently tracking transient state that the app should not need to concern itself with saving and restoring, but that the framework should take special note to preserve when possible.

        A view with transient state cannot be trivially rebound from an external data source, such as an adapter binding item views in a list. This may be because the view is performing an animation, tracking user selection of content, or similar.

        Returns:
        true if the view has transient state
      • setHasTransientState

        public void setHasTransientState(boolean hasTransientState)
        Set whether this view is currently tracking transient state that the framework should attempt to preserve when possible. This flag is reference counted, so every call to setHasTransientState(true) should be paired with a later call to setHasTransientState(false).

        A view with transient state cannot be trivially rebound from an external data source, such as an adapter binding item views in a list. This may be because the view is performing an animation, tracking user selection of content, or similar.

        Parameters:
        hasTransientState - true if this view has transient state
      • setWillNotDraw

        public void setWillNotDraw(boolean willNotDraw)
        If this view doesn't do any drawing on its own, set this flag to allow further optimizations. By default, this flag is not set on View, but could be set on some View subclasses such as ViewGroup. Typically, if you override onDraw(android.graphics.Canvas) you should clear this flag.
        Parameters:
        willNotDraw - whether or not this View draw on its own
      • willNotDraw

        public boolean willNotDraw()
        Returns whether or not this View draws on its own.
        Returns:
        true if this view has nothing to draw, false otherwise
      • setWillNotCacheDrawing

        public void setWillNotCacheDrawing(boolean willNotCacheDrawing)
        When a View's drawing cache is enabled, drawing is redirected to an offscreen bitmap. Some views, like an ImageView, must be able to bypass this mechanism if they already draw a single bitmap, to avoid unnecessary usage of the memory.
        Parameters:
        willNotCacheDrawing - true if this view does not cache its drawing, false otherwise
      • willNotCacheDrawing

        public boolean willNotCacheDrawing()
        Returns whether or not this View can cache its drawing or not.
        Returns:
        true if this view does not cache its drawing, false otherwise
      • isClickable

        public boolean isClickable()
        Indicates whether this view reacts to click events or not.
        Returns:
        true if the view is clickable, false otherwise
        See Also:
        setClickable(boolean)
      • setClickable

        public void setClickable(boolean clickable)
        Enables or disables click events for this view. When a view is clickable it will change its state to "pressed" on every click. Subclasses should set the view clickable to visually react to user's clicks.
        Parameters:
        clickable - true to make the view clickable, false otherwise
        See Also:
        isClickable()
      • isLongClickable

        public boolean isLongClickable()
        Indicates whether this view reacts to long click events or not.
        Returns:
        true if the view is long clickable, false otherwise
        See Also:
        setLongClickable(boolean)
      • setLongClickable

        public void setLongClickable(boolean longClickable)
        Enables or disables long click events for this view. When a view is long clickable it reacts to the user holding down the button for a longer duration than a tap. This event can either launch the listener or a context menu.
        Parameters:
        longClickable - true to make the view long clickable, false otherwise
        See Also:
        isLongClickable()
      • setPressed

        public void setPressed(boolean pressed)
        Sets the pressed state for this view.
        Parameters:
        pressed - Pass true to set the View's internal state to "pressed", or false to reverts the View's internal state from a previously set "pressed" state.
        See Also:
        isClickable(), setClickable(boolean)
      • dispatchSetPressed

        protected void dispatchSetPressed(boolean pressed)
        Dispatch setPressed to all of this View's children.
        Parameters:
        pressed - The new pressed state
        See Also:
        setPressed(boolean)
      • isSaveEnabled

        public boolean isSaveEnabled()
        Indicates whether this view will save its state (that is, whether its onSaveInstanceState() method will be called).
        Returns:
        Returns true if the view state saving is enabled, else false.
        See Also:
        setSaveEnabled(boolean)
      • setSaveEnabled

        public void setSaveEnabled(boolean enabled)
        Controls whether the saving of this view's state is enabled (that is, whether its onSaveInstanceState() method will be called). Note that even if freezing is enabled, the view still must have an id assigned to it (via setId(int)) for its state to be saved. This flag can only disable the saving of this view; any child views may still have their state saved.
        Parameters:
        enabled - Set to false to disable state saving, or true (the default) to allow it.
        See Also:
        isSaveEnabled(), setId(int), onSaveInstanceState()
      • getFilterTouchesWhenObscured

        public boolean getFilterTouchesWhenObscured()
        Gets whether the framework should discard touches when the view's window is obscured by another visible window. Refer to the View security documentation for more details.
        Returns:
        True if touch filtering is enabled.
        See Also:
        setFilterTouchesWhenObscured(boolean)
      • setFilterTouchesWhenObscured

        public void setFilterTouchesWhenObscured(boolean enabled)
        Sets whether the framework should discard touches when the view's window is obscured by another visible window. Refer to the View security documentation for more details.
        Parameters:
        enabled - True if touch filtering should be enabled.
        See Also:
        getFilterTouchesWhenObscured()
      • isSaveFromParentEnabled

        public boolean isSaveFromParentEnabled()
        Indicates whether the entire hierarchy under this view will save its state when a state saving traversal occurs from its parent. The default is true; if false, these views will not be saved unless saveHierarchyState(SparseArray) is called directly on this view.
        Returns:
        Returns true if the view state saving from parent is enabled, else false.
        See Also:
        setSaveFromParentEnabled(boolean)
      • setSaveFromParentEnabled

        public void setSaveFromParentEnabled(boolean enabled)
        Controls whether the entire hierarchy under this view will save its state when a state saving traversal occurs from its parent. The default is true; if false, these views will not be saved unless saveHierarchyState(SparseArray) is called directly on this view.
        Parameters:
        enabled - Set to false to disable state saving, or true (the default) to allow it.
        See Also:
        isSaveFromParentEnabled(), setId(int), onSaveInstanceState()
      • isFocusable

        public final boolean isFocusable()
        Returns whether this View is able to take focus.
        Returns:
        True if this view can take focus, or false otherwise.
      • isFocusableInTouchMode

        public final boolean isFocusableInTouchMode()
        When a view is focusable, it may not want to take focus when in touch mode. For example, a button would like focus when the user is navigating via a D-pad so that the user can click on it, but once the user starts touching the screen, the button shouldn't take focus
        Returns:
        Whether the view is focusable in touch mode.
      • focusSearch

        public View focusSearch(int direction)
        Find the nearest view in the specified direction that can take focus. This does not actually give focus to that view.
        Parameters:
        direction - One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT
        Returns:
        The nearest focusable in the specified direction, or null if none can be found.
      • dispatchUnhandledMove

        public boolean dispatchUnhandledMove(View focused,
                                    int direction)
        This method is the last chance for the focused view and its ancestors to respond to an arrow key. This is called when the focused view did not consume the key internally, nor could the view system find a new view in the requested direction to give focus to.
        Parameters:
        focused - The currently focused view.
        direction - The direction focus wants to move. One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT.
        Returns:
        True if the this view consumed this unhandled move.
      • getFocusables

        public ArrayList<View> getFocusables(int direction)
        Find and return all focusable views that are descendants of this view, possibly including this view if it is focusable itself.
        Parameters:
        direction - The direction of the focus
        Returns:
        A list of focusable views
      • addFocusables

        public void addFocusables(ArrayList<View> views,
                         int direction)
        Add any focusable views that are descendants of this view (possibly including this view if it is focusable itself) to views. If we are in touch mode, only add views that are also focusable in touch mode.
        Parameters:
        views - Focusable views found so far
        direction - The direction of the focus
      • addFocusables

        public void addFocusables(ArrayList<View> views,
                         int direction,
                         int focusableMode)
        Adds any focusable views that are descendants of this view (possibly including this view if it is focusable itself) to views. This method adds all focusable views regardless if we are in touch mode or only views focusable in touch mode if we are in touch mode or only views that can take accessibility focus if accessibility is enabeld depending on the focusable mode paramater.
        Parameters:
        views - Focusable views found so far or null if all we are interested is the number of focusables.
        direction - The direction of the focus.
        focusableMode - The type of focusables to be added.
        See Also:
        FOCUSABLES_ALL, FOCUSABLES_TOUCH_MODE
      • getTouchables

        public ArrayList<View> getTouchables()
        Find and return all touchable views that are descendants of this view, possibly including this view if it is touchable itself.
        Returns:
        A list of touchable views
      • addTouchables

        public void addTouchables(ArrayList<View> views)
        Add any touchable views that are descendants of this view (possibly including this view if it is touchable itself) to views.
        Parameters:
        views - Touchable views found so far
      • requestAccessibilityFocus

        public boolean requestAccessibilityFocus()
        Call this to try to give accessibility focus to this view. A view will not actually take focus if AccessibilityManager.isEnabled() returns false or the view is no visible or the view already has accessibility focus. See also focusSearch(int), which is what you call to say that you have focus, and you want your parent to look for the next one.
        Returns:
        Whether this view actually took accessibility focus.
      • clearAccessibilityFocus

        public void clearAccessibilityFocus()
        Call this to try to clear accessibility focus of this view. See also focusSearch(int), which is what you call to say that you have focus, and you want your parent to look for the next one.
      • requestFocus

        public final boolean requestFocus()
        Call this to try to give focus to a specific view or to one of its descendants. A view will not actually take focus if it is not focusable (isFocusable() returns false), or if it is focusable and it is not focusable in touch mode (isFocusableInTouchMode()) while the device is in touch mode. See also focusSearch(int), which is what you call to say that you have focus, and you want your parent to look for the next one. This is equivalent to calling requestFocus(int, Rect) with arguments FOCUS_DOWN and null.
        Returns:
        Whether this view or one of its descendants actually took focus.
      • requestFocus

        public final boolean requestFocus(int direction)
        Call this to try to give focus to a specific view or to one of its descendants and give it a hint about what direction focus is heading. A view will not actually take focus if it is not focusable (isFocusable() returns false), or if it is focusable and it is not focusable in touch mode (isFocusableInTouchMode()) while the device is in touch mode. See also focusSearch(int), which is what you call to say that you have focus, and you want your parent to look for the next one. This is equivalent to calling requestFocus(int, Rect) with null set for the previously focused rectangle.
        Parameters:
        direction - One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT
        Returns:
        Whether this view or one of its descendants actually took focus.
      • requestFocus

        public boolean requestFocus(int direction,
                           Rect previouslyFocusedRect)
        Call this to try to give focus to a specific view or to one of its descendants and give it hints about the direction and a specific rectangle that the focus is coming from. The rectangle can help give larger views a finer grained hint about where focus is coming from, and therefore, where to show selection, or forward focus change internally. A view will not actually take focus if it is not focusable (isFocusable() returns false), or if it is focusable and it is not focusable in touch mode (isFocusableInTouchMode()) while the device is in touch mode. A View will not take focus if it is not visible. A View will not take focus if one of its parents has ViewGroup.getDescendantFocusability() equal to ViewGroup.FOCUS_BLOCK_DESCENDANTS. See also focusSearch(int), which is what you call to say that you have focus, and you want your parent to look for the next one. You may wish to override this method if your custom View has an internal View that it wishes to forward the request to.
        Parameters:
        direction - One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT
        previouslyFocusedRect - The rectangle (in this View's coordinate system) to give a finer grained hint about where focus is coming from. May be null if there is no hint.
        Returns:
        Whether this view or one of its descendants actually took focus.
      • requestFocusFromTouch

        public final boolean requestFocusFromTouch()
        Call this to try to give focus to a specific view or to one of its descendants. This is a special variant of requestFocus() that will allow views that are not focuable in touch mode to request focus when they are touched.
        Returns:
        Whether this view or one of its descendants actually took focus.
        See Also:
        isInTouchMode()
      • isImportantForAccessibility

        public boolean isImportantForAccessibility()
        Gets whether this view should be exposed for accessibility.
        Returns:
        Whether the view is exposed for accessibility.
      • getParentForAccessibility

        public ViewParent getParentForAccessibility()
        Gets the parent for accessibility purposes. Note that the parent for accessibility is not necessary the immediate parent. It is the first predecessor that is important for accessibility.
        Returns:
        The parent for accessibility purposes.
      • addChildrenForAccessibility

        public void addChildrenForAccessibility(ArrayList<View> children)
        Adds the children of a given View for accessibility. Since some Views are not important for accessibility the children for accessibility are not necessarily direct children of the riew, rather they are the first level of descendants important for accessibility.
        Parameters:
        children - The list of children for accessibility.
      • includeForAccessibility

        public boolean includeForAccessibility()
        Whether to regard this view for accessibility. A view is regarded for accessibility if it is important for accessibility or the querying accessibility service has explicitly requested that view not important for accessibility are regarded.
        Returns:
        Whether to regard the view for accessibility.
      • isActionableForAccessibility

        public boolean isActionableForAccessibility()
        Returns whether the View is considered actionable from accessibility perspective. Such view are important for accessibility.
        Returns:
        True if the view is actionable for accessibility.
      • notifyAccessibilityStateChanged

        public void notifyAccessibilityStateChanged()
        Notifies accessibility services that some view's important for accessibility state has changed. Note that such notifications are made at most once every ViewConfiguration.getSendRecurringAccessibilityEventsInterval() to avoid unnecessary load to the system. Also once a view has made a notifucation this method is a NOP until the notification has been sent to clients.
      • resetAccessibilityStateChanged

        public void resetAccessibilityStateChanged()
        Reset the state indicating the this view has requested clients interested in its accessibility state to be notified.
      • getIterableTextForAccessibility

        public CharSequence getIterableTextForAccessibility()
        Gets the text reported for accessibility purposes.
        Returns:
        The accessibility text.
      • getAccessibilityCursorPosition

        public int getAccessibilityCursorPosition()
      • setAccessibilityCursorPosition

        public void setAccessibilityCursorPosition(int position)
      • dispatchStartTemporaryDetach

        public void dispatchStartTemporaryDetach()
      • dispatchFinishTemporaryDetach

        public void dispatchFinishTemporaryDetach()
      • onFinishTemporaryDetach

        public void onFinishTemporaryDetach()
        Called after onStartTemporaryDetach() when the container is done changing the view.
      • dispatchKeyEventPreIme

        public boolean dispatchKeyEventPreIme(KeyEvent event)
        Dispatch a key event before it is processed by any input method associated with the view hierarchy. This can be used to intercept key events in special situations before the IME consumes them; a typical example would be handling the BACK key to update the application's UI instead of allowing the IME to see it and close itself.
        Parameters:
        event - The key event to be dispatched.
        Returns:
        True if the event was handled, false otherwise.
      • dispatchKeyEvent

        public boolean dispatchKeyEvent(KeyEvent event)
        Dispatch a key event to the next view on the focus path. This path runs from the top of the view tree down to the currently focused view. If this view has focus, it will dispatch to itself. Otherwise it will dispatch the next node down the focus path. This method also fires any key listeners.
        Parameters:
        event - The key event to be dispatched.
        Returns:
        True if the event was handled, false otherwise.
      • dispatchKeyShortcutEvent

        public boolean dispatchKeyShortcutEvent(KeyEvent event)
        Dispatches a key shortcut event.
        Parameters:
        event - The key event to be dispatched.
        Returns:
        True if the event was handled by the view, false otherwise.
      • dispatchTouchEvent

        public boolean dispatchTouchEvent(MotionEvent event)
        Pass the touch screen motion event down to the target view, or this view if it is the target.
        Parameters:
        event - The motion event to be dispatched.
        Returns:
        True if the event was handled by the view, false otherwise.
      • onFilterTouchEventForSecurity

        public boolean onFilterTouchEventForSecurity(MotionEvent event)
        Filter the touch event to apply security policies.
        Parameters:
        event - The motion event to be filtered.
        Returns:
        True if the event should be dispatched, false if the event should be dropped.
        See Also:
        getFilterTouchesWhenObscured()
      • dispatchTrackballEvent

        public boolean dispatchTrackballEvent(MotionEvent event)
        Pass a trackball motion event down to the focused view.
        Parameters:
        event - The motion event to be dispatched.
        Returns:
        True if the event was handled by the view, false otherwise.
      • dispatchGenericMotionEvent

        public boolean dispatchGenericMotionEvent(MotionEvent event)
        Dispatch a generic motion event.

        Generic motion events with source class InputDevice.SOURCE_CLASS_POINTER are delivered to the view under the pointer. All other generic motion events are delivered to the focused view. Hover events are handled specially and are delivered to onHoverEvent(MotionEvent).

        Parameters:
        event - The motion event to be dispatched.
        Returns:
        True if the event was handled by the view, false otherwise.
      • dispatchHoverEvent

        protected boolean dispatchHoverEvent(MotionEvent event)
        Dispatch a hover event.

        Do not call this method directly. Call dispatchGenericMotionEvent(MotionEvent) instead.

        Parameters:
        event - The motion event to be dispatched.
        Returns:
        True if the event was handled by the view, false otherwise.
      • hasHoveredChild

        protected boolean hasHoveredChild()
        Returns true if the view has a child to which it has recently sent MotionEvent.ACTION_HOVER_ENTER. If this view is hovered and it does not have a hovered child, then it must be the innermost hovered view.
      • dispatchGenericPointerEvent

        protected boolean dispatchGenericPointerEvent(MotionEvent event)
        Dispatch a generic motion event to the view under the first pointer.

        Do not call this method directly. Call dispatchGenericMotionEvent(MotionEvent) instead.

        Parameters:
        event - The motion event to be dispatched.
        Returns:
        True if the event was handled by the view, false otherwise.
      • dispatchGenericFocusedEvent

        protected boolean dispatchGenericFocusedEvent(MotionEvent event)
        Dispatch a generic motion event to the currently focused view.

        Do not call this method directly. Call dispatchGenericMotionEvent(MotionEvent) instead.

        Parameters:
        event - The motion event to be dispatched.
        Returns:
        True if the event was handled by the view, false otherwise.
      • dispatchPointerEvent

        public final boolean dispatchPointerEvent(MotionEvent event)
        Dispatch a pointer event.

        Dispatches touch related pointer events to onTouchEvent(MotionEvent) and all other events to onGenericMotionEvent(MotionEvent). This separation of concerns reinforces the invariant that onTouchEvent(MotionEvent) is really about touches and should not be expected to handle other pointing device features.

        Parameters:
        event - The motion event to be dispatched.
        Returns:
        True if the event was handled by the view, false otherwise.
      • dispatchWindowFocusChanged

        public void dispatchWindowFocusChanged(boolean hasFocus)
        Called when the window containing this view gains or loses window focus. ViewGroups should override to route to their children.
        Parameters:
        hasFocus - True if the window containing this view now has focus, false otherwise.
      • onWindowFocusChanged

        public void onWindowFocusChanged(boolean hasWindowFocus)
        Called when the window containing this view gains or loses focus. Note that this is separate from view focus: to receive key events, both your view and its window must have focus. If a window is displayed on top of yours that takes input focus, then your own window will lose focus but the view focus will remain unchanged.
        Parameters:
        hasWindowFocus - True if the window containing this view now has focus, false otherwise.
      • hasWindowFocus

        public boolean hasWindowFocus()
        Returns true if this view is in a window that currently has window focus. Note that this is not the same as the view itself having focus.
        Returns:
        True if this view is in a window that currently has window focus.
      • dispatchVisibilityChanged

        protected void dispatchVisibilityChanged(View changedView,
                                     int visibility)
        Dispatch a view visibility change down the view hierarchy. ViewGroups should override to route to their children.
        Parameters:
        changedView - The view whose visibility changed. Could be 'this' or an ancestor view.
        visibility - The new visibility of changedView: VISIBLE, INVISIBLE or GONE.
      • onVisibilityChanged

        protected void onVisibilityChanged(View changedView,
                               int visibility)
        Called when the visibility of the view or an ancestor of the view is changed.
        Parameters:
        changedView - The view whose visibility changed. Could be 'this' or an ancestor view.
        visibility - The new visibility of changedView: VISIBLE, INVISIBLE or GONE.
      • dispatchDisplayHint

        public void dispatchDisplayHint(int hint)
        Dispatch a hint about whether this view is displayed. For instance, when a View moves out of the screen, it might receives a display hint indicating the view is not displayed. Applications should not rely on this hint as there is no guarantee that they will receive one.
        Parameters:
        hint - A hint about whether or not this view is displayed: VISIBLE or INVISIBLE.
      • onDisplayHint

        protected void onDisplayHint(int hint)
        Gives this view a hint about whether is displayed or not. For instance, when a View moves out of the screen, it might receives a display hint indicating the view is not displayed. Applications should not rely on this hint as there is no guarantee that they will receive one.
        Parameters:
        hint - A hint about whether or not this view is displayed: VISIBLE or INVISIBLE.
      • dispatchWindowVisibilityChanged

        public void dispatchWindowVisibilityChanged(int visibility)
        Dispatch a window visibility change down the view hierarchy. ViewGroups should override to route to their children.
        Parameters:
        visibility - The new visibility of the window.
        See Also:
        onWindowVisibilityChanged(int)
      • onWindowVisibilityChanged

        protected void onWindowVisibilityChanged(int visibility)
        Called when the window containing has change its visibility (between GONE, INVISIBLE, and VISIBLE). Note that this tells you whether or not your window is being made visible to the window manager; this does not tell you whether or not your window is obscured by other windows on the screen, even if it is itself visible.
        Parameters:
        visibility - The new visibility of the window.
      • getWindowVisibility

        public int getWindowVisibility()
        Returns the current visibility of the window this view is attached to (either GONE, INVISIBLE, or VISIBLE).
        Returns:
        Returns the current visibility of the view's window.
      • getWindowVisibleDisplayFrame

        public void getWindowVisibleDisplayFrame(Rect outRect)
        Retrieve the overall visible display size in which the window this view is attached to has been positioned in. This takes into account screen decorations above the window, for both cases where the window itself is being position inside of them or the window is being placed under then and covered insets are used for the window to position its content inside. In effect, this tells you the available area where content can be placed and remain visible to users.

        This function requires an IPC back to the window manager to retrieve the requested information, so should not be used in performance critical code like drawing.

        Parameters:
        outRect - Filled in with the visible display frame. If the view is not attached to a window, this is simply the raw display size.
      • dispatchConfigurationChanged

        public void dispatchConfigurationChanged(Configuration newConfig)
        Dispatch a notification about a resource configuration change down the view hierarchy. ViewGroups should override to route to their children.
        Parameters:
        newConfig - The new resource configuration.
        See Also:
        onConfigurationChanged(android.content.res.Configuration)
      • onConfigurationChanged

        protected void onConfigurationChanged(Configuration newConfig)
        Called when the current configuration of the resources being used by the application have changed. You can use this to decide when to reload resources that can changed based on orientation and other configuration characterstics. You only need to use this if you are not relying on the normal Activity mechanism of recreating the activity instance upon a configuration change.
        Parameters:
        newConfig - The new resource configuration.
      • isInTouchMode

        public boolean isInTouchMode()
        Returns whether the device is currently in touch mode. Touch mode is entered once the user begins interacting with the device by touch, and affects various things like whether focus is always visible to the user.
        Returns:
        Whether the device is in touch mode.
      • getContext

        public final Context getContext()
        Returns the context the view is running in, through which it can access the current theme, resources, etc.
        Returns:
        The view's Context.
      • onKeyPreIme

        public boolean onKeyPreIme(int keyCode,
                          KeyEvent event)
        Handle a key event before it is processed by any input method associated with the view hierarchy. This can be used to intercept key events in special situations before the IME consumes them; a typical example would be handling the BACK key to update the application's UI instead of allowing the IME to see it and close itself.
        Parameters:
        keyCode - The value in event.getKeyCode().
        event - Description of the key event.
        Returns:
        If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.
      • onKeyDown

        public boolean onKeyDown(int keyCode,
                        KeyEvent event)
        Default implementation of KeyEvent.Callback.onKeyDown(): perform press of the view when KeyEvent.KEYCODE_DPAD_CENTER or KeyEvent.KEYCODE_ENTER is released, if the view is enabled and clickable.

        Key presses in software keyboards will generally NOT trigger this listener, although some may elect to do so in some situations. Do not rely on this to catch software key presses.

        Specified by:
        onKeyDown in interface KeyEvent.Callback
        Parameters:
        keyCode - A key code that represents the button pressed, from KeyEvent.
        event - The KeyEvent object that defines the button action.
        Returns:
        If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.
      • onKeyLongPress

        public boolean onKeyLongPress(int keyCode,
                             KeyEvent event)
        Default implementation of KeyEvent.Callback.onKeyLongPress(): always returns false (doesn't handle the event).

        Key presses in software keyboards will generally NOT trigger this listener, although some may elect to do so in some situations. Do not rely on this to catch software key presses.

        Specified by:
        onKeyLongPress in interface KeyEvent.Callback
        Parameters:
        keyCode - The value in event.getKeyCode().
        event - Description of the key event.
        Returns:
        If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.
      • onKeyUp

        public boolean onKeyUp(int keyCode,
                      KeyEvent event)
        Default implementation of KeyEvent.Callback.onKeyUp(): perform clicking of the view when KeyEvent.KEYCODE_DPAD_CENTER or KeyEvent.KEYCODE_ENTER is released.

        Key presses in software keyboards will generally NOT trigger this listener, although some may elect to do so in some situations. Do not rely on this to catch software key presses.

        Specified by:
        onKeyUp in interface KeyEvent.Callback
        Parameters:
        keyCode - A key code that represents the button pressed, from KeyEvent.
        event - The KeyEvent object that defines the button action.
        Returns:
        If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.
      • onKeyMultiple

        public boolean onKeyMultiple(int keyCode,
                            int repeatCount,
                            KeyEvent event)
        Default implementation of KeyEvent.Callback.onKeyMultiple(): always returns false (doesn't handle the event).

        Key presses in software keyboards will generally NOT trigger this listener, although some may elect to do so in some situations. Do not rely on this to catch software key presses.

        Specified by:
        onKeyMultiple in interface KeyEvent.Callback
        Parameters:
        keyCode - A key code that represents the button pressed, from KeyEvent.
        repeatCount - The number of times the action was made.
        event - The KeyEvent object that defines the button action.
        Returns:
        If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.
      • onKeyShortcut

        public boolean onKeyShortcut(int keyCode,
                            KeyEvent event)
        Called on the focused view when a key shortcut event is not handled. Override this method to implement local key shortcuts for the View. Key shortcuts can also be implemented by setting the shortcut property of menu items.
        Parameters:
        keyCode - The value in event.getKeyCode().
        event - Description of the key event.
        Returns:
        If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.
      • onCheckIsTextEditor

        public boolean onCheckIsTextEditor()
        Check whether the called view is a text editor, in which case it would make sense to automatically display a soft input window for it. Subclasses should override this if they implement onCreateInputConnection(EditorInfo) to return true if a call on that method would return a non-null InputConnection, and they are really a first-class editor that the user would normally start typing on when the go into a window containing your view.

        The default implementation always returns false. This does not mean that its onCreateInputConnection(EditorInfo) will not be called or the user can not otherwise perform edits on your view; it is just a hint to the system that this is not the primary purpose of this view.

        Returns:
        Returns true if this view is a text editor, else false.
      • onCreateInputConnection

        public InputConnection onCreateInputConnection(EditorInfo outAttrs)
        Create a new InputConnection for an InputMethod to interact with the view. The default implementation returns null, since it doesn't support input methods. You can override this to implement such support. This is only needed for views that take focus and text input.

        When implementing this, you probably also want to implement onCheckIsTextEditor() to indicate you will return a non-null InputConnection.

        Parameters:
        outAttrs - Fill in with attribute information about the connection.
      • checkInputConnectionProxy

        public boolean checkInputConnectionProxy(View view)
        Called by the InputMethodManager when a view who is not the current input connection target is trying to make a call on the manager. The default implementation returns false; you can override this to return true for certain views if you are performing InputConnection proxying to them.
        Parameters:
        view - The View that is making the InputMethodManager call.
        Returns:
        Return true to allow the call, false to reject.
      • createContextMenu

        public void createContextMenu(ContextMenu menu)
        Show the context menu for this view. It is not safe to hold on to the menu after returning from this method. You should normally not overload this method. Overload onCreateContextMenu(ContextMenu) or define an View.OnCreateContextMenuListener to add items to the context menu.
        Parameters:
        menu - The context menu to populate
      • getContextMenuInfo

        protected ContextMenu.ContextMenuInfo getContextMenuInfo()
        Views should implement this if they have extra information to associate with the context menu. The return result is supplied as a parameter to the OnCreateContextMenuListener#onCreateContextMenu(ContextMenu, View, ContextMenuInfo) callback.
        Returns:
        Extra information about the item for which the context menu should be shown. This information will vary across different subclasses of View.
      • onCreateContextMenu

        protected void onCreateContextMenu(ContextMenu menu)
        Views should implement this if the view itself is going to add items to the context menu.
        Parameters:
        menu - the context menu to populate
      • onTrackballEvent

        public boolean onTrackballEvent(MotionEvent event)
        Implement this method to handle trackball motion events. The relative movement of the trackball since the last event can be retrieve with MotionEvent.getX() and MotionEvent.getY(). These are normalized so that a movement of 1 corresponds to the user pressing one DPAD key (so they will often be fractional values, representing the more fine-grained movement information available from a trackball).
        Parameters:
        event - The motion event.
        Returns:
        True if the event was handled, false otherwise.
      • onGenericMotionEvent

        public boolean onGenericMotionEvent(MotionEvent event)
        Implement this method to handle generic motion events.

        Generic motion events describe joystick movements, mouse hovers, track pad touches, scroll wheel movements and other input events. The source of the motion event specifies the class of input that was received. Implementations of this method must examine the bits in the source before processing the event. The following code example shows how this is done.

        Generic motion events with source class InputDevice.SOURCE_CLASS_POINTER are delivered to the view under the pointer. All other generic motion events are delivered to the focused view.

         public boolean onGenericMotionEvent(MotionEvent event) {
             if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
                 if (event.getAction() == MotionEvent.ACTION_MOVE) {
                     // process the joystick movement...
                     return true;
                 }
             }
             if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
                 switch (event.getAction()) {
                     case MotionEvent.ACTION_HOVER_MOVE:
                         // process the mouse hover movement...
                         return true;
                     case MotionEvent.ACTION_SCROLL:
                         // process the scroll wheel movement...
                         return true;
                 }
             }
             return super.onGenericMotionEvent(event);
         }
        Parameters:
        event - The generic motion event being processed.
        Returns:
        True if the event was handled, false otherwise.
      • onHoverEvent

        public boolean onHoverEvent(MotionEvent event)
        Implement this method to handle hover events.

        This method is called whenever a pointer is hovering into, over, or out of the bounds of a view and the view is not currently being touched. Hover events are represented as pointer events with action MotionEvent.ACTION_HOVER_ENTER, MotionEvent.ACTION_HOVER_MOVE, or MotionEvent.ACTION_HOVER_EXIT.

        • The view receives a hover event with action MotionEvent.ACTION_HOVER_ENTER when the pointer enters the bounds of the view.
        • The view receives a hover event with action MotionEvent.ACTION_HOVER_MOVE when the pointer has already entered the bounds of the view and has moved.
        • The view receives a hover event with action MotionEvent.ACTION_HOVER_EXIT when the pointer has exited the bounds of the view or when the pointer is about to go down due to a button click, tap, or similar user action that causes the view to be touched.

        The view should implement this method to return true to indicate that it is handling the hover event, such as by changing its drawable state.

        The default implementation calls setHovered(boolean) to update the hovered state of the view when a hover enter or hover exit event is received, if the view is enabled and is clickable. The default implementation also sends hover accessibility events.

        Parameters:
        event - The motion event that describes the hover.
        Returns:
        True if the view handled the hover event.
        See Also:
        isHovered(), setHovered(boolean), onHoverChanged(boolean)
      • setHovered

        public void setHovered(boolean hovered)
        Sets whether the view is currently hovered.

        Calling this method also changes the drawable state of the view. This enables the view to react to hover by using different drawable resources to change its appearance.

        The onHoverChanged(boolean) method is called when the hovered state changes.

        Parameters:
        hovered - True if the view is hovered.
        See Also:
        isHovered(), onHoverChanged(boolean)
      • onHoverChanged

        public void onHoverChanged(boolean hovered)
        Implement this method to handle hover state changes.

        This method is called whenever the hover state changes as a result of a call to setHovered(boolean).

        Parameters:
        hovered - The current hover state, as returned by isHovered().
        See Also:
        isHovered(), setHovered(boolean)
      • onTouchEvent

        public boolean onTouchEvent(MotionEvent event)
        Implement this method to handle touch screen motion events.
        Parameters:
        event - The motion event.
        Returns:
        True if the event was handled, false otherwise.
      • isInScrollingContainer

        public boolean isInScrollingContainer()
      • cancelLongPress

        public void cancelLongPress()
        Cancels a pending long press. Your subclass can use this if you want the context menu to come up if the user presses and holds at the same place, but you don't want it to come up if they press and then move around enough to cause scrolling.
      • setTouchDelegate

        public void setTouchDelegate(TouchDelegate delegate)
        Sets the TouchDelegate for this View.
      • getTouchDelegate

        public TouchDelegate getTouchDelegate()
        Gets the TouchDelegate for this View.
      • bringToFront

        public void bringToFront()
        Change the view's z order in the tree, so it's on top of other sibling views
      • onScrollChanged

        protected void onScrollChanged(int l,
                           int t,
                           int oldl,
                           int oldt)
        This is called in response to an internal scroll in this view (i.e., the view scrolled its own contents). This is typically as a result of scrollBy(int, int) or scrollTo(int, int) having been called.
        Parameters:
        l - Current horizontal scroll origin.
        t - Current vertical scroll origin.
        oldl - Previous horizontal scroll origin.
        oldt - Previous vertical scroll origin.
      • onSizeChanged

        protected void onSizeChanged(int w,
                         int h,
                         int oldw,
                         int oldh)
        This is called during layout when the size of this view has changed. If you were just added to the view hierarchy, you're called with the old values of 0.
        Parameters:
        w - Current width of this view.
        h - Current height of this view.
        oldw - Old width of this view.
        oldh - Old height of this view.
      • dispatchDraw

        protected void dispatchDraw(Canvas canvas)
        Called by draw to draw the child views. This may be overridden by derived classes to gain control just before its children are drawn (but after its own view has been drawn).
        Parameters:
        canvas - the canvas on which to draw the view
      • getParent

        public final ViewParent getParent()
        Gets the parent of this view. Note that the parent is a ViewParent and not necessarily a View.
        Returns:
        Parent of this view.
      • setScrollX

        public void setScrollX(int value)
        Set the horizontal scrolled position of your view. This will cause a call to onScrollChanged(int, int, int, int) and the view will be invalidated.
        Parameters:
        value - the x position to scroll to
      • setScrollY

        public void setScrollY(int value)
        Set the vertical scrolled position of your view. This will cause a call to onScrollChanged(int, int, int, int) and the view will be invalidated.
        Parameters:
        value - the y position to scroll to
      • getScrollX

        public final int getScrollX()
        Return the scrolled left position of this view. This is the left edge of the displayed part of your view. You do not need to draw any pixels farther left, since those are outside of the frame of your view on screen.
        Returns:
        The left edge of the displayed part of your view, in pixels.
      • getScrollY

        public final int getScrollY()
        Return the scrolled top position of this view. This is the top edge of the displayed part of your view. You do not need to draw any pixels above it, since those are outside of the frame of your view on screen.
        Returns:
        The top edge of the displayed part of your view, in pixels.
      • getWidth

        public final int getWidth()
        Return the width of the your view.
        Returns:
        The width of your view, in pixels.
      • getHeight

        public final int getHeight()
        Return the height of your view.
        Returns:
        The height of your view, in pixels.
      • getDrawingRect

        public void getDrawingRect(Rect outRect)
        Return the visible drawing bounds of your view. Fills in the output rectangle with the values from getScrollX(), getScrollY(), getWidth(), and getHeight(). These bounds do not account for any transformation properties currently set on the view, such as setScaleX(float) or setRotation(float).
        Parameters:
        outRect - The (scrolled) drawing bounds of the view.
      • getMeasuredWidth

        public final int getMeasuredWidth()
        Like getMeasuredWidthAndState(), but only returns the raw width component (that is the result is masked by MEASURED_SIZE_MASK).
        Returns:
        The raw measured width of this view.
      • getMeasuredWidthAndState

        public final int getMeasuredWidthAndState()
        Return the full width measurement information for this view as computed by the most recent call to measure(int, int). This result is a bit mask as defined by MEASURED_SIZE_MASK and MEASURED_STATE_TOO_SMALL. This should be used during measurement and layout calculations only. Use getWidth() to see how wide a view is after layout.
        Returns:
        The measured width of this view as a bit mask.
      • getMeasuredHeight

        public final int getMeasuredHeight()
        Like getMeasuredHeightAndState(), but only returns the raw width component (that is the result is masked by MEASURED_SIZE_MASK).
        Returns:
        The raw measured height of this view.
      • getMeasuredHeightAndState

        public final int getMeasuredHeightAndState()
        Return the full height measurement information for this view as computed by the most recent call to measure(int, int). This result is a bit mask as defined by MEASURED_SIZE_MASK and MEASURED_STATE_TOO_SMALL. This should be used during measurement and layout calculations only. Use getHeight() to see how wide a view is after layout.
        Returns:
        The measured width of this view as a bit mask.
      • getCameraDistance

        public float getCameraDistance()
        Gets the distance along the Z axis from the camera to this view.
        Returns:
        The distance along the Z axis.
        See Also:
        setCameraDistance(float)
      • setCameraDistance

        public void setCameraDistance(float distance)

        Sets the distance along the Z axis (orthogonal to the X/Y plane on which views are drawn) from the camera to this view. The camera's distance affects 3D transformations, for instance rotations around the X and Y axis. If the rotationX or rotationY properties are changed and this view is large (more than half the size of the screen), it is recommended to always use a camera distance that's greater than the height (X axis rotation) or the width (Y axis rotation) of this view.

        The distance of the camera from the view plane can have an affect on the perspective distortion of the view when it is rotated around the x or y axis. For example, a large distance will result in a large viewing angle, and there will not be much perspective distortion of the view as it rotates. A short distance may cause much more perspective distortion upon rotation, and can also result in some drawing artifacts if the rotated view ends up partially behind the camera (which is why the recommendation is to use a distance at least as far as the size of the view, if the view is to be rotated.)

        The distance is expressed in "depth pixels." The default distance depends on the screen density. For instance, on a medium density display, the default distance is 1280. On a high density display, the default distance is 1920.

        If you want to specify a distance that leads to visually consistent results across various densities, use the following formula:

         float scale = context.getResources().getDisplayMetrics().density;
         view.setCameraDistance(distance * scale);
         

        The density scale factor of a high density display is 1.5, and 1920 = 1280 * 1.5.

        Parameters:
        distance - The distance in "depth pixels", if negative the opposite value is used
        See Also:
        setRotationX(float), setRotationY(float)
      • getRotationY

        public float getRotationY()
        The degrees that the view is rotated around the vertical axis through the pivot point.
        Returns:
        The degrees of Y rotation.
        See Also:
        getPivotX(), getPivotY(), setRotationY(float)
      • getRotationX

        public float getRotationX()
        The degrees that the view is rotated around the horizontal axis through the pivot point.
        Returns:
        The degrees of X rotation.
        See Also:
        getPivotX(), getPivotY(), setRotationX(float)
      • getScaleX

        public float getScaleX()
        The amount that the view is scaled in x around the pivot point, as a proportion of the view's unscaled width. A value of 1, the default, means that no scaling is applied.

        By default, this is 1.0f.

        Returns:
        The scaling factor.
        See Also:
        getPivotX(), getPivotY()
      • setScaleX

        public void setScaleX(float scaleX)
        Sets the amount that the view is scaled in x around the pivot point, as a proportion of the view's unscaled width. A value of 1 means that no scaling is applied.
        Parameters:
        scaleX - The scaling factor.
        See Also:
        getPivotX(), getPivotY()
      • getScaleY

        public float getScaleY()
        The amount that the view is scaled in y around the pivot point, as a proportion of the view's unscaled height. A value of 1, the default, means that no scaling is applied.

        By default, this is 1.0f.

        Returns:
        The scaling factor.
        See Also:
        getPivotX(), getPivotY()
      • setScaleY

        public void setScaleY(float scaleY)
        Sets the amount that the view is scaled in Y around the pivot point, as a proportion of the view's unscaled width. A value of 1 means that no scaling is applied.
        Parameters:
        scaleY - The scaling factor.
        See Also:
        getPivotX(), getPivotY()
      • setPivotX

        public void setPivotX(float pivotX)
        Sets the x location of the point around which the view is rotated and scaled. By default, the pivot point is centered on the object. Setting this property disables this behavior and causes the view to use only the explicitly set pivotX and pivotY values.
        Parameters:
        pivotX - The x location of the pivot point.
        See Also:
        getRotation(), getScaleX(), getScaleY(), getPivotY()
      • setPivotY

        public void setPivotY(float pivotY)
        Sets the y location of the point around which the view is rotated and scaled. By default, the pivot point is centered on the object. Setting this property disables this behavior and causes the view to use only the explicitly set pivotX and pivotY values.
        Parameters:
        pivotY - The y location of the pivot point.
        See Also:
        getRotation(), getScaleX(), getScaleY(), getPivotY()
      • getAlpha

        public float getAlpha()
        The opacity of the view. This is a value from 0 to 1, where 0 means the view is completely transparent and 1 means the view is completely opaque.

        By default this is 1.0f.

        Returns:
        The opacity of the view.
      • hasOverlappingRendering

        public boolean hasOverlappingRendering()
        Returns whether this View has content which overlaps. This function, intended to be overridden by specific View types, is an optimization when alpha is set on a view. If rendering overlaps in a view with alpha < 1, that view is drawn to an offscreen buffer and then composited it into place, which can be expensive. if the view has no overlapping rendering, the view can draw each primitive with the appropriate alpha value directly. an example of overlapping rendering is a textview with a background image, such as a button. an example of non-overlapping rendering is a textview with no background, or an imageview with only the foreground image. the default implementation returns true; subclasses should override if they have cases which can be optimized.
        Returns:
        true if the content in this view might overlap, false otherwise.
      • setAlpha

        public void setAlpha(float alpha)

        Sets the opacity of the view. This is a value from 0 to 1, where 0 means the view is completely transparent and 1 means the view is completely opaque.

        If this view overrides onSetAlpha(int) to return true, then this view is responsible for applying the opacity itself. Otherwise, calling this method is equivalent to calling setLayerType(int, android.graphics.Paint) and setting a hardware layer.

        Note that setting alpha to a translucent value (0 < alpha < 1) may have performance implications. it is generally best to use the alpha property sparingly and transiently, as in the case of fading animations.

        Parameters:
        alpha - The opacity of the view.
        See Also:
        setLayerType(int, android.graphics.Paint)
      • getTop

        public final int getTop()
        Top position of this view relative to its parent.
        Returns:
        The top of this view, in pixels.
      • setTop

        public final void setTop(int top)
        Sets the top position of this view relative to its parent. This method is meant to be called by the layout system and should not generally be called otherwise, because the property may be changed at any time by the layout.
        Parameters:
        top - The top of this view, in pixels.
      • getBottom

        public final int getBottom()
        Bottom position of this view relative to its parent.
        Returns:
        The bottom of this view, in pixels.
      • isDirty

        public boolean isDirty()
        True if this view has changed since the last time being drawn.
        Returns:
        The dirty state of this view.
      • setBottom

        public final void setBottom(int bottom)
        Sets the bottom position of this view relative to its parent. This method is meant to be called by the layout system and should not generally be called otherwise, because the property may be changed at any time by the layout.
        Parameters:
        bottom - The bottom of this view, in pixels.
      • getLeft

        public final int getLeft()
        Left position of this view relative to its parent.
        Returns:
        The left edge of this view, in pixels.
      • setLeft

        public final void setLeft(int left)
        Sets the left position of this view relative to its parent. This method is meant to be called by the layout system and should not generally be called otherwise, because the property may be changed at any time by the layout.
        Parameters:
        left - The bottom of this view, in pixels.
      • getRight

        public final int getRight()
        Right position of this view relative to its parent.
        Returns:
        The right edge of this view, in pixels.
      • setRight

        public final void setRight(int right)
        Sets the right position of this view relative to its parent. This method is meant to be called by the layout system and should not generally be called otherwise, because the property may be changed at any time by the layout.
        Parameters:
        right - The bottom of this view, in pixels.
      • getX

        public float getX()
        The visual x position of this view, in pixels. This is equivalent to the translationX property plus the current left property.
        Returns:
        The visual x position of this view, in pixels.
      • setX

        public void setX(float x)
        Sets the visual x position of this view, in pixels. This is equivalent to setting the translationX property to be the difference between the x value passed in and the current left property.
        Parameters:
        x - The visual x position of this view, in pixels.
      • getY

        public float getY()
        The visual y position of this view, in pixels. This is equivalent to the translationY property plus the current top property.
        Returns:
        The visual y position of this view, in pixels.
      • setY

        public void setY(float y)
        Sets the visual y position of this view, in pixels. This is equivalent to setting the translationY property to be the difference between the y value passed in and the current top property.
        Parameters:
        y - The visual y position of this view, in pixels.
      • getTranslationX

        public float getTranslationX()
        The horizontal location of this view relative to its left position. This position is post-layout, in addition to wherever the object's layout placed it.
        Returns:
        The horizontal position of this view relative to its left position, in pixels.
      • setTranslationX

        public void setTranslationX(float translationX)
        Sets the horizontal location of this view relative to its left position. This effectively positions the object post-layout, in addition to wherever the object's layout placed it.
        Parameters:
        translationX - The horizontal position of this view relative to its left position, in pixels.
      • getTranslationY

        public float getTranslationY()
        The horizontal location of this view relative to its top position. This position is post-layout, in addition to wherever the object's layout placed it.
        Returns:
        The vertical position of this view relative to its top position, in pixels.
      • setTranslationY

        public void setTranslationY(float translationY)
        Sets the vertical location of this view relative to its top position. This effectively positions the object post-layout, in addition to wherever the object's layout placed it.
        Parameters:
        translationY - The vertical position of this view relative to its top position, in pixels.
      • getHitRect

        public void getHitRect(Rect outRect)
        Hit rectangle in parent's coordinates
        Parameters:
        outRect - The hit rectangle of the view.
      • getFocusedRect

        public void getFocusedRect(Rect r)
        When a view has focus and the user navigates away from it, the next view is searched for starting from the rectangle filled in by this method. By default, the rectangle is the getDrawingRect(android.graphics.Rect)) of the view. However, if your view maintains some idea of internal selection, such as a cursor, or a selected row or column, you should override this method and fill in a more specific rectangle.
        Parameters:
        r - The rectangle to fill in, in this view's coordinates.
      • getGlobalVisibleRect

        public boolean getGlobalVisibleRect(Rect r,
                                   Point globalOffset)
        If some part of this view is not clipped by any of its parents, then return that area in r in global (root) coordinates. To convert r to local coordinates (without taking possible View rotations into account), offset it by -globalOffset (e.g. r.offset(-globalOffset.x, -globalOffset.y)). If the view is completely clipped or translated out, return false.
        Parameters:
        r - If true is returned, r holds the global coordinates of the visible portion of this view.
        globalOffset - If true is returned, globalOffset holds the dx,dy between this view and its root. globalOffet may be null.
        Returns:
        true if r is non-empty (i.e. part of the view is visible at the root level.
      • getGlobalVisibleRect

        public final boolean getGlobalVisibleRect(Rect r)
      • getLocalVisibleRect

        public final boolean getLocalVisibleRect(Rect r)
      • offsetTopAndBottom

        public void offsetTopAndBottom(int offset)
        Offset this view's vertical location by the specified number of pixels.
        Parameters:
        offset - the number of pixels to offset the view by
      • offsetLeftAndRight

        public void offsetLeftAndRight(int offset)
        Offset this view's horizontal location by the specified amount of pixels.
        Parameters:
        offset - the numer of pixels to offset the view by
      • getLayoutParams

        public ViewGroup.LayoutParams getLayoutParams()
        Get the LayoutParams associated with this view. All views should have layout parameters. These supply parameters to the parent of this view specifying how it should be arranged. There are many subclasses of ViewGroup.LayoutParams, and these correspond to the different subclasses of ViewGroup that are responsible for arranging their children. This method may return null if this View is not attached to a parent ViewGroup or setLayoutParams(android.view.ViewGroup.LayoutParams) was not invoked successfully. When a View is attached to a parent ViewGroup, this method must not return null.
        Returns:
        The LayoutParams associated with this view, or null if no parameters have been set yet
      • setLayoutParams

        public void setLayoutParams(ViewGroup.LayoutParams params)
        Set the layout parameters associated with this view. These supply parameters to the parent of this view specifying how it should be arranged. There are many subclasses of ViewGroup.LayoutParams, and these correspond to the different subclasses of ViewGroup that are responsible for arranging their children.
        Parameters:
        params - The layout parameters for this view, cannot be null
      • resolveLayoutParams

        public void resolveLayoutParams()
        Resolve the layout parameters depending on the resolved layout direction
      • scrollTo

        public void scrollTo(int x,
                    int y)
        Set the scrolled position of your view. This will cause a call to onScrollChanged(int, int, int, int) and the view will be invalidated.
        Parameters:
        x - the x position to scroll to
        y - the y position to scroll to
      • scrollBy

        public void scrollBy(int x,
                    int y)
        Move the scrolled position of your view. This will cause a call to onScrollChanged(int, int, int, int) and the view will be invalidated.
        Parameters:
        x - the amount of pixels to scroll by horizontally
        y - the amount of pixels to scroll by vertically
      • awakenScrollBars

        protected boolean awakenScrollBars(int startDelay,
                               boolean invalidate)

        Trigger the scrollbars to draw. When invoked this method starts an animation to fade the scrollbars out after a fixed delay. If a subclass provides animated scrolling, the start delay should equal the duration of the scrolling animation.

        The animation starts only if at least one of the scrollbars is enabled, as specified by isHorizontalScrollBarEnabled() and isVerticalScrollBarEnabled(). When the animation is started, this method returns true, and false otherwise. If the animation is started, this method calls invalidate() if the invalidate parameter is set to true; in that case the caller should not call invalidate().

        This method should be invoked everytime a subclass directly updates the scroll parameters.

        Parameters:
        startDelay - the delay, in milliseconds, after which the animation should start; when the delay is 0, the animation starts immediately
        invalidate - Wheter this method should call invalidate
        Returns:
        true if the animation is played, false otherwise
        See Also:
        scrollBy(int, int), scrollTo(int, int), isHorizontalScrollBarEnabled(), isVerticalScrollBarEnabled(), setHorizontalScrollBarEnabled(boolean), setVerticalScrollBarEnabled(boolean)
      • invalidate

        public void invalidate(Rect dirty)
        Mark the area defined by dirty as needing to be drawn. If the view is visible, onDraw(android.graphics.Canvas) will be called at some point in the future. This must be called from a UI thread. To call from a non-UI thread, call postInvalidate(). WARNING: This method is destructive to dirty.
        Parameters:
        dirty - the rectangle representing the bounds of the dirty region
      • invalidate

        public void invalidate(int l,
                      int t,
                      int r,
                      int b)
        Mark the area defined by the rect (l,t,r,b) as needing to be drawn. The coordinates of the dirty rect are relative to the view. If the view is visible, onDraw(android.graphics.Canvas) will be called at some point in the future. This must be called from a UI thread. To call from a non-UI thread, call postInvalidate().
        Parameters:
        l - the left position of the dirty region
        t - the top position of the dirty region
        r - the right position of the dirty region
        b - the bottom position of the dirty region
      • invalidate

        public void invalidate()
        Invalidate the whole view. If the view is visible, onDraw(android.graphics.Canvas) will be called at some point in the future. This must be called from a UI thread. To call from a non-UI thread, call postInvalidate().
      • invalidateParentCaches

        protected void invalidateParentCaches()
        Used to indicate that the parent of this view should clear its caches. This functionality is used to force the parent to rebuild its display list (when hardware-accelerated), which is necessary when various parent-managed properties of the view change, such as alpha, translationX/Y, scrollX/Y, scaleX/Y, and rotation/X/Y. This method only clears the parent caches and does not causes an invalidate event.
      • invalidateParentIfNeeded

        protected void invalidateParentIfNeeded()
        Used to indicate that the parent of this view should be invalidated. This functionality is used to force the parent to rebuild its display list (when hardware-accelerated), which is necessary when various parent-managed properties of the view change, such as alpha, translationX/Y, scrollX/Y, scaleX/Y, and rotation/X/Y. This method will propagate an invalidation event to the parent.
      • isOpaque

        public boolean isOpaque()
        Indicates whether this View is opaque. An opaque View guarantees that it will draw all the pixels overlapping its bounds using a fully opaque color. Subclasses of View should override this method whenever possible to indicate whether an instance is opaque. Opaque Views are treated in a special way by the View hierarchy, possibly allowing it to perform optimizations during invalidate/draw passes.
        Returns:
        True if this View is guaranteed to be fully opaque, false otherwise.
      • computeOpaqueFlags

        protected void computeOpaqueFlags()
      • hasOpaqueScrollbars

        protected boolean hasOpaqueScrollbars()
      • getHandler

        public Handler getHandler()
        Returns:
        A handler associated with the thread running the View. This handler can be used to pump events in the UI events queue.
      • getViewRootImpl

        public ViewRootImpl getViewRootImpl()
        Gets the view root associated with the View.
        Returns:
        The view root, or null if none.
      • post

        public boolean post(Runnable action)

        Causes the Runnable to be added to the message queue. The runnable will be run on the user interface thread.

        Parameters:
        action - The Runnable that will be executed.
        Returns:
        Returns true if the Runnable was successfully placed in to the message queue. Returns false on failure, usually because the looper processing the message queue is exiting.
        See Also:
        postDelayed(java.lang.Runnable, long), removeCallbacks(java.lang.Runnable)
      • postDelayed

        public boolean postDelayed(Runnable action,
                          long delayMillis)

        Causes the Runnable to be added to the message queue, to be run after the specified amount of time elapses. The runnable will be run on the user interface thread.

        Parameters:
        action - The Runnable that will be executed.
        delayMillis - The delay (in milliseconds) until the Runnable will be executed.
        Returns:
        true if the Runnable was successfully placed in to the message queue. Returns false on failure, usually because the looper processing the message queue is exiting. Note that a result of true does not mean the Runnable will be processed -- if the looper is quit before the delivery time of the message occurs then the message will be dropped.
        See Also:
        post(java.lang.Runnable), removeCallbacks(java.lang.Runnable)
      • postOnAnimationDelayed

        public void postOnAnimationDelayed(Runnable action,
                                  long delayMillis)

        Causes the Runnable to execute on the next animation time step, after the specified amount of time elapses. The runnable will be run on the user interface thread.

        Parameters:
        action - The Runnable that will be executed.
        delayMillis - The delay (in milliseconds) until the Runnable will be executed.
        See Also:
        postOnAnimation(java.lang.Runnable), removeCallbacks(java.lang.Runnable)
      • postInvalidate

        public void postInvalidate()

        Cause an invalidate to happen on a subsequent cycle through the event loop. Use this to invalidate the View from a non-UI thread.

        This method can be invoked from outside of the UI thread only when this View is attached to a window.

        See Also:
        invalidate(), postInvalidateDelayed(long)
      • postInvalidate

        public void postInvalidate(int left,
                          int top,
                          int right,
                          int bottom)

        Cause an invalidate of the specified area to happen on a subsequent cycle through the event loop. Use this to invalidate the View from a non-UI thread.

        This method can be invoked from outside of the UI thread only when this View is attached to a window.

        Parameters:
        left - The left coordinate of the rectangle to invalidate.
        top - The top coordinate of the rectangle to invalidate.
        right - The right coordinate of the rectangle to invalidate.
        bottom - The bottom coordinate of the rectangle to invalidate.
        See Also:
        invalidate(int, int, int, int), invalidate(Rect), postInvalidateDelayed(long, int, int, int, int)
      • postInvalidateDelayed

        public void postInvalidateDelayed(long delayMilliseconds)

        Cause an invalidate to happen on a subsequent cycle through the event loop. Waits for the specified amount of time.

        This method can be invoked from outside of the UI thread only when this View is attached to a window.

        Parameters:
        delayMilliseconds - the duration in milliseconds to delay the invalidation by
        See Also:
        invalidate(), postInvalidate()
      • postInvalidateDelayed

        public void postInvalidateDelayed(long delayMilliseconds,
                                 int left,
                                 int top,
                                 int right,
                                 int bottom)

        Cause an invalidate of the specified area to happen on a subsequent cycle through the event loop. Waits for the specified amount of time.

        This method can be invoked from outside of the UI thread only when this View is attached to a window.

        Parameters:
        delayMilliseconds - the duration in milliseconds to delay the invalidation by
        left - The left coordinate of the rectangle to invalidate.
        top - The top coordinate of the rectangle to invalidate.
        right - The right coordinate of the rectangle to invalidate.
        bottom - The bottom coordinate of the rectangle to invalidate.
        See Also:
        invalidate(int, int, int, int), invalidate(Rect), postInvalidate(int, int, int, int)
      • postInvalidateOnAnimation

        public void postInvalidateOnAnimation()

        Cause an invalidate to happen on the next animation time step, typically the next display frame.

        This method can be invoked from outside of the UI thread only when this View is attached to a window.

        See Also:
        invalidate()
      • postInvalidateOnAnimation

        public void postInvalidateOnAnimation(int left,
                                     int top,
                                     int right,
                                     int bottom)

        Cause an invalidate of the specified area to happen on the next animation time step, typically the next display frame.

        This method can be invoked from outside of the UI thread only when this View is attached to a window.

        Parameters:
        left - The left coordinate of the rectangle to invalidate.
        top - The top coordinate of the rectangle to invalidate.
        right - The right coordinate of the rectangle to invalidate.
        bottom - The bottom coordinate of the rectangle to invalidate.
        See Also:
        invalidate(int, int, int, int), invalidate(Rect)
      • computeScroll

        public void computeScroll()
        Called by a parent to request that a child update its values for mScrollX and mScrollY if necessary. This will typically be done if the child is animating a scroll using a Scroller object.
      • isHorizontalFadingEdgeEnabled

        public boolean isHorizontalFadingEdgeEnabled()

        Indicate whether the horizontal edges are faded when the view is scrolled horizontally.

        Returns:
        true if the horizontal edges should are faded on scroll, false otherwise
        See Also:
        setHorizontalFadingEdgeEnabled(boolean)
      • setHorizontalFadingEdgeEnabled

        public void setHorizontalFadingEdgeEnabled(boolean horizontalFadingEdgeEnabled)

        Define whether the horizontal edges should be faded when this view is scrolled horizontally.

        Parameters:
        horizontalFadingEdgeEnabled - true if the horizontal edges should be faded when the view is scrolled horizontally
        See Also:
        isHorizontalFadingEdgeEnabled()
      • isVerticalFadingEdgeEnabled

        public boolean isVerticalFadingEdgeEnabled()

        Indicate whether the vertical edges are faded when the view is scrolled horizontally.

        Returns:
        true if the vertical edges should are faded on scroll, false otherwise
        See Also:
        setVerticalFadingEdgeEnabled(boolean)
      • setVerticalFadingEdgeEnabled

        public void setVerticalFadingEdgeEnabled(boolean verticalFadingEdgeEnabled)

        Define whether the vertical edges should be faded when this view is scrolled vertically.

        Parameters:
        verticalFadingEdgeEnabled - true if the vertical edges should be faded when the view is scrolled vertically
        See Also:
        isVerticalFadingEdgeEnabled()
      • getTopFadingEdgeStrength

        protected float getTopFadingEdgeStrength()
        Returns the strength, or intensity, of the top faded edge. The strength is a value between 0.0 (no fade) and 1.0 (full fade). The default implementation returns 0.0 or 1.0 but no value in between. Subclasses should override this method to provide a smoother fade transition when scrolling occurs.
        Returns:
        the intensity of the top fade as a float between 0.0f and 1.0f
      • getBottomFadingEdgeStrength

        protected float getBottomFadingEdgeStrength()
        Returns the strength, or intensity, of the bottom faded edge. The strength is a value between 0.0 (no fade) and 1.0 (full fade). The default implementation returns 0.0 or 1.0 but no value in between. Subclasses should override this method to provide a smoother fade transition when scrolling occurs.
        Returns:
        the intensity of the bottom fade as a float between 0.0f and 1.0f
      • getLeftFadingEdgeStrength

        protected float getLeftFadingEdgeStrength()
        Returns the strength, or intensity, of the left faded edge. The strength is a value between 0.0 (no fade) and 1.0 (full fade). The default implementation returns 0.0 or 1.0 but no value in between. Subclasses should override this method to provide a smoother fade transition when scrolling occurs.
        Returns:
        the intensity of the left fade as a float between 0.0f and 1.0f
      • getRightFadingEdgeStrength

        protected float getRightFadingEdgeStrength()
        Returns the strength, or intensity, of the right faded edge. The strength is a value between 0.0 (no fade) and 1.0 (full fade). The default implementation returns 0.0 or 1.0 but no value in between. Subclasses should override this method to provide a smoother fade transition when scrolling occurs.
        Returns:
        the intensity of the right fade as a float between 0.0f and 1.0f
      • isHorizontalScrollBarEnabled

        public boolean isHorizontalScrollBarEnabled()

        Indicate whether the horizontal scrollbar should be drawn or not. The scrollbar is not drawn by default.

        Returns:
        true if the horizontal scrollbar should be painted, false otherwise
        See Also:
        setHorizontalScrollBarEnabled(boolean)
      • setHorizontalScrollBarEnabled

        public void setHorizontalScrollBarEnabled(boolean horizontalScrollBarEnabled)

        Define whether the horizontal scrollbar should be drawn or not. The scrollbar is not drawn by default.

        Parameters:
        horizontalScrollBarEnabled - true if the horizontal scrollbar should be painted
        See Also:
        isHorizontalScrollBarEnabled()
      • isVerticalScrollBarEnabled

        public boolean isVerticalScrollBarEnabled()

        Indicate whether the vertical scrollbar should be drawn or not. The scrollbar is not drawn by default.

        Returns:
        true if the vertical scrollbar should be painted, false otherwise
        See Also:
        setVerticalScrollBarEnabled(boolean)
      • setVerticalScrollBarEnabled

        public void setVerticalScrollBarEnabled(boolean verticalScrollBarEnabled)

        Define whether the vertical scrollbar should be drawn or not. The scrollbar is not drawn by default.

        Parameters:
        verticalScrollBarEnabled - true if the vertical scrollbar should be painted
        See Also:
        isVerticalScrollBarEnabled()
      • recomputePadding

        protected void recomputePadding()
      • setScrollbarFadingEnabled

        public void setScrollbarFadingEnabled(boolean fadeScrollbars)
        Define whether scrollbars will fade when the view is not scrolling.
        Parameters:
        fadeScrollbars - wheter to enable fading
      • isScrollbarFadingEnabled

        public boolean isScrollbarFadingEnabled()
        Returns true if scrollbars will fade when this view is not scrolling
        Returns:
        true if scrollbar fading is enabled
      • getScrollBarDefaultDelayBeforeFade

        public int getScrollBarDefaultDelayBeforeFade()
        Returns the delay before scrollbars fade.
        Returns:
        the delay before scrollbars fade
      • setScrollBarDefaultDelayBeforeFade

        public void setScrollBarDefaultDelayBeforeFade(int scrollBarDefaultDelayBeforeFade)
        Define the delay before scrollbars fade.
        Parameters:
        scrollBarDefaultDelayBeforeFade - - the delay before scrollbars fade
      • getScrollBarFadeDuration

        public int getScrollBarFadeDuration()
        Returns the scrollbar fade duration.
        Returns:
        the scrollbar fade duration
      • setScrollBarFadeDuration

        public void setScrollBarFadeDuration(int scrollBarFadeDuration)
        Define the scrollbar fade duration.
        Parameters:
        scrollBarFadeDuration - - the scrollbar fade duration
      • getScrollBarSize

        public int getScrollBarSize()
        Returns the scrollbar size.
        Returns:
        the scrollbar size
      • setScrollBarSize

        public void setScrollBarSize(int scrollBarSize)
        Define the scrollbar size.
        Parameters:
        scrollBarSize - - the scrollbar size
      • setScrollBarStyle

        public void setScrollBarStyle(int style)

        Specify the style of the scrollbars. The scrollbars can be overlaid or inset. When inset, they add to the padding of the view. And the scrollbars can be drawn inside the padding area or on the edge of the view. For example, if a view has a background drawable and you want to draw the scrollbars inside the padding specified by the drawable, you can use SCROLLBARS_INSIDE_OVERLAY or SCROLLBARS_INSIDE_INSET. If you want them to appear at the edge of the view, ignoring the padding, then you can use SCROLLBARS_OUTSIDE_OVERLAY or SCROLLBARS_OUTSIDE_INSET.

        Parameters:
        style - the style of the scrollbars. Should be one of SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_INSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY or SCROLLBARS_OUTSIDE_INSET.
        See Also:
        SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_INSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET
      • canScrollHorizontally

        public boolean canScrollHorizontally(int direction)
        Check if this view can be scrolled horizontally in a certain direction.
        Parameters:
        direction - Negative to check scrolling left, positive to check scrolling right.
        Returns:
        true if this view can be scrolled in the specified direction, false otherwise.
      • canScrollVertically

        public boolean canScrollVertically(int direction)
        Check if this view can be scrolled vertically in a certain direction.
        Parameters:
        direction - Negative to check scrolling up, positive to check scrolling down.
        Returns:
        true if this view can be scrolled in the specified direction, false otherwise.
      • onDrawScrollBars

        protected final void onDrawScrollBars(Canvas canvas)

        Request the drawing of the horizontal and the vertical scrollbar. The scrollbars are painted only if they have been awakened first.

        Parameters:
        canvas - the canvas on which to draw the scrollbars
        See Also:
        awakenScrollBars(int)
      • isVerticalScrollBarHidden

        protected boolean isVerticalScrollBarHidden()
        Override this if the vertical scrollbar needs to be hidden in a subclass, like when FastScroller is visible.
        Returns:
        whether to temporarily hide the vertical scrollbar
      • onDraw

        protected void onDraw(Canvas canvas)
        Implement this to do your drawing.
        Parameters:
        canvas - the canvas on which the background will be drawn
      • onAttachedToWindow

        protected void onAttachedToWindow()
        This is called when the view is attached to a window. At this point it has a Surface and will start drawing. Note that this function is guaranteed to be called before onDraw(android.graphics.Canvas), however it may be called any time before the first onDraw -- including before or after onMeasure(int, int).
        See Also:
        onDetachedFromWindow()
      • resolveRtlPropertiesIfNeeded

        public void resolveRtlPropertiesIfNeeded()
        Resolve all RTL related properties.
      • resetRtlProperties

        public void resetRtlProperties()
        Reset resolution of all RTL related properties.
      • onScreenStateChanged

        public void onScreenStateChanged(int screenState)
        This method is called whenever the state of the screen this view is attached to changes. A state change will usually occurs when the screen turns on or off (whether it happens automatically or the user does it manually.)
        Parameters:
        screenState - The new state of the screen. Can be either SCREEN_STATE_ON or SCREEN_STATE_OFF
      • onRtlPropertiesChanged

        public void onRtlPropertiesChanged(int layoutDirection)
        Called when any RTL property (layout direction or text direction or text alignment) has been changed. Subclasses need to override this method to take care of cached information that depends on the resolved layout direction, or to inform child views that inherit their layout direction. The default implementation does nothing.
        Parameters:
        layoutDirection - the direction of the layout
        See Also:
        LAYOUT_DIRECTION_LTR, LAYOUT_DIRECTION_RTL
      • resolveLayoutDirection

        public boolean resolveLayoutDirection()
        Resolve and cache the layout direction. LTR is set initially. This is implicitly supposing that the parent directionality can and will be resolved before its children.
        Returns:
        true if resolution has been done, false otherwise.
      • canResolveLayoutDirection

        public boolean canResolveLayoutDirection()
        Check if layout direction resolution can be done.
        Returns:
        true if layout direction resolution can be done otherwise return false.
      • resetResolvedLayoutDirection

        public void resetResolvedLayoutDirection()
        Reset the resolved layout direction. Layout direction will be resolved during a call to onMeasure(int, int).
      • isLayoutDirectionInherited

        public boolean isLayoutDirectionInherited()
        Returns:
        true if the layout direction is inherited.
      • resolvePadding

        public void resolvePadding()
        Resolve padding depending on layout direction.
      • resetResolvedPadding

        public void resetResolvedPadding()
        Reset the resolved layout direction.
      • onDetachedFromWindow

        protected void onDetachedFromWindow()
        This is called when the view is detached from a window. At this point it no longer has a surface for drawing.
        See Also:
        onAttachedToWindow()
      • getWindowAttachCount

        protected int getWindowAttachCount()
        Returns:
        The number of times this view has been attached to a window
      • getWindowToken

        public IBinder getWindowToken()
        Retrieve a unique token identifying the window this view is attached to.
        Returns:
        Return the window's token for use in WindowManager.LayoutParams.token.
      • getApplicationWindowToken

        public IBinder getApplicationWindowToken()
        Retrieve a unique token identifying the top-level "real" window of the window that this view is attached to. That is, this is like getWindowToken(), except if the window this view in is a panel window (attached to another containing window), then the token of the containing window is returned instead.
        Returns:
        Returns the associated window token, either getWindowToken() or the containing window's token.
      • getDisplay

        public Display getDisplay()
        Gets the logical display to which the view's window has been attached.
        Returns:
        The logical display, or null if the view is not currently attached to a window.
      • onSaveInstanceState

        protected Parcelable onSaveInstanceState()
        Hook allowing a view to generate a representation of its internal state that can later be used to create a new instance with that same state. This state should only contain information that is not persistent or can not be reconstructed later. For example, you will never store your current position on screen because that will be computed again when a new instance of the view is placed in its view hierarchy.

        Some examples of things you may store here: the current cursor position in a text view (but usually not the text itself since that is stored in a content provider or other persistent storage), the currently selected item in a list view.

        Returns:
        Returns a Parcelable object containing the view's current dynamic state, or null if there is nothing interesting to save. The default implementation returns null.
        See Also:
        onRestoreInstanceState(android.os.Parcelable), saveHierarchyState(android.util.SparseArray), dispatchSaveInstanceState(android.util.SparseArray), setSaveEnabled(boolean)
      • getDrawingTime

        public long getDrawingTime()

        Return the time at which the drawing of the view hierarchy started.

        Returns:
        the drawing start time in milliseconds
      • setDuplicateParentStateEnabled

        public void setDuplicateParentStateEnabled(boolean enabled)

        Enables or disables the duplication of the parent's state into this view. When duplication is enabled, this view gets its drawable state from its parent rather than from its own internal properties.

        Note: in the current implementation, setting this property to true after the view was added to a ViewGroup might have no effect at all. This property should always be used from XML or set to true before adding this view to a ViewGroup.

        Note: if this view's parent addStateFromChildren property is enabled and this property is enabled, an exception will be thrown.

        Note: if the child view uses and updates additionnal states which are unknown to the parent, these states should not be affected by this method.

        Parameters:
        enabled - True to enable duplication of the parent's drawable state, false to disable it.
        See Also:
        getDrawableState(), isDuplicateParentStateEnabled()
      • isDuplicateParentStateEnabled

        public boolean isDuplicateParentStateEnabled()

        Indicates whether this duplicates its drawable state from its parent.

        Returns:
        True if this view's drawable state is duplicated from the parent, false otherwise
        See Also:
        getDrawableState(), setDuplicateParentStateEnabled(boolean)
      • buildLayer

        public void buildLayer()
        Forces this view's layer to be created and this view to be rendered into its layer. If this view's layer type is set to LAYER_TYPE_NONE, invoking this method will have no effect. This method can for instance be used to render a view into its layer before starting an animation. If this view is complex, rendering into the layer before starting the animation will avoid skipping frames.
        Throws:
        IllegalStateException - If this view is not attached to a window
        See Also:
        setLayerType(int, android.graphics.Paint)
      • destroyHardwareResources

        protected void destroyHardwareResources()
        Destroys all hardware rendering resources. This method is invoked when the system needs to reclaim resources. Upon execution of this method, you should free any OpenGL resources created by the view. Note: you must call super.destroyHardwareResources() when overriding this method.
      • outputDirtyFlags

        public void outputDirtyFlags(String indent,
                            boolean clear,
                            int clearMask)
        Debugging utility which recursively outputs the dirty state of a view and its descendants.
      • dispatchGetDisplayList

        protected void dispatchGetDisplayList()
        This method is used by ViewGroup to cause its children to restore or recreate their display lists. It is called by getDisplayList() when the parent ViewGroup does not need to recreate its own display list, which would happen if it went through the normal draw/dispatchDraw mechanisms.
      • canHaveDisplayList

        public boolean canHaveDisplayList()
        A view that is not attached or hardware accelerated cannot create a display list. This method checks these conditions and returns the appropriate result.
        Returns:
        true if view has the ability to create a display list, false otherwise.
      • getHardwareRenderer

        public HardwareRenderer getHardwareRenderer()
        Returns:
        The HardwareRenderer associated with that view or null if hardware rendering is not supported or this this has not been attached to a window.
      • getDisplayList

        public DisplayList getDisplayList()

        Returns a display list that can be used to draw this view again without executing its draw method.

        Returns:
        A DisplayList ready to replay, or null if caching is not enabled.
      • getDrawingCache

        public Bitmap getDrawingCache()

        Calling this method is equivalent to calling getDrawingCache(false).

        Returns:
        A non-scaled bitmap representing this view or null if cache is disabled.
        See Also:
        getDrawingCache(boolean)
      • getDrawingCache

        public Bitmap getDrawingCache(boolean autoScale)

        Returns the bitmap in which this view drawing is cached. The returned bitmap is null when caching is disabled. If caching is enabled and the cache is not ready, this method will create it. Calling draw(android.graphics.Canvas) will not draw from the cache when the cache is enabled. To benefit from the cache, you must request the drawing cache by calling this method and draw it on screen if the returned bitmap is not null.

        Note about auto scaling in compatibility mode: When auto scaling is not enabled, this method will create a bitmap of the same size as this view. Because this bitmap will be drawn scaled by the parent ViewGroup, the result on screen might show scaling artifacts. To avoid such artifacts, you should call this method by setting the auto scaling to true. Doing so, however, will generate a bitmap of a different size than the view. This implies that your application must be able to handle this size.

        Parameters:
        autoScale - Indicates whether the generated bitmap should be scaled based on the current density of the screen when the application is in compatibility mode.
        Returns:
        A bitmap representing this view or null if cache is disabled.
        See Also:
        setDrawingCacheEnabled(boolean), isDrawingCacheEnabled(), buildDrawingCache(boolean), destroyDrawingCache()
      • setDrawingCacheBackgroundColor

        public void setDrawingCacheBackgroundColor(int color)
        Setting a solid background color for the drawing cache's bitmaps will improve performance and memory usage. Note, though that this should only be used if this view will always be drawn on top of a solid color.
        Parameters:
        color - The background color to use for the drawing cache's bitmap
        See Also:
        setDrawingCacheEnabled(boolean), buildDrawingCache(), getDrawingCache()
      • getDrawingCacheBackgroundColor

        public int getDrawingCacheBackgroundColor()
        Returns:
        The background color to used for the drawing cache's bitmap
        See Also:
        setDrawingCacheBackgroundColor(int)
      • buildDrawingCache

        public void buildDrawingCache()

        Calling this method is equivalent to calling buildDrawingCache(false).

        See Also:
        buildDrawingCache(boolean)
      • buildDrawingCache

        public void buildDrawingCache(boolean autoScale)

        Forces the drawing cache to be built if the drawing cache is invalid.

        If you call buildDrawingCache() manually without calling setDrawingCacheEnabled(true), you should cleanup the cache by calling destroyDrawingCache() afterwards.

        Note about auto scaling in compatibility mode: When auto scaling is not enabled, this method will create a bitmap of the same size as this view. Because this bitmap will be drawn scaled by the parent ViewGroup, the result on screen might show scaling artifacts. To avoid such artifacts, you should call this method by setting the auto scaling to true. Doing so, however, will generate a bitmap of a different size than the view. This implies that your application must be able to handle this size.

        You should avoid calling this method when hardware acceleration is enabled. If you do not need the drawing cache bitmap, calling this method will increase memory usage and cause the view to be rendered in software once, thus negatively impacting performance.

        See Also:
        getDrawingCache(), destroyDrawingCache()
      • isInEditMode

        public boolean isInEditMode()
        Indicates whether this View is currently in edit mode. A View is usually in edit mode when displayed within a developer tool. For instance, if this View is being drawn by a visual user interface builder, this method should return true. Subclasses should check the return value of this method to provide different behaviors if their normal behavior might interfere with the host environment. For instance: the class spawns a thread in its constructor, the drawing code relies on device-specific features, etc. This method is usually checked in the drawing code of custom widgets.
        Returns:
        True if this View is in edit mode, false otherwise.
      • isPaddingOffsetRequired

        protected boolean isPaddingOffsetRequired()
        If the View draws content inside its padding and enables fading edges, it needs to support padding offsets. Padding offsets are added to the fading edges to extend the length of the fade so that it covers pixels drawn inside the padding. Subclasses of this class should override this method if they need to draw content inside the padding.
        Returns:
        True if padding offset must be applied, false otherwise.
        Since:
        CURRENT
        See Also:
        getLeftPaddingOffset(), getRightPaddingOffset(), getTopPaddingOffset(), getBottomPaddingOffset()
      • getLeftPaddingOffset

        protected int getLeftPaddingOffset()
        Amount by which to extend the left fading region. Called only when isPaddingOffsetRequired() returns true.
        Returns:
        The left padding offset in pixels.
        Since:
        CURRENT
        See Also:
        isPaddingOffsetRequired()
      • getRightPaddingOffset

        protected int getRightPaddingOffset()
        Amount by which to extend the right fading region. Called only when isPaddingOffsetRequired() returns true.
        Returns:
        The right padding offset in pixels.
        Since:
        CURRENT
        See Also:
        isPaddingOffsetRequired()
      • getTopPaddingOffset

        protected int getTopPaddingOffset()
        Amount by which to extend the top fading region. Called only when isPaddingOffsetRequired() returns true.
        Returns:
        The top padding offset in pixels.
        Since:
        CURRENT
        See Also:
        isPaddingOffsetRequired()
      • getBottomPaddingOffset

        protected int getBottomPaddingOffset()
        Amount by which to extend the bottom fading region. Called only when isPaddingOffsetRequired() returns true.
        Returns:
        The bottom padding offset in pixels.
        Since:
        CURRENT
        See Also:
        isPaddingOffsetRequired()
      • getFadeTop

        protected int getFadeTop(boolean offsetRequired)
        Parameters:
        offsetRequired -
      • getFadeHeight

        protected int getFadeHeight(boolean offsetRequired)
        Parameters:
        offsetRequired -
      • isHardwareAccelerated

        public boolean isHardwareAccelerated()

        Indicates whether this view is attached to a hardware accelerated window or not.

        Even if this method returns true, it does not mean that every call to draw(android.graphics.Canvas) will be made with an hardware accelerated Canvas. For instance, if this view is drawn onto an offscreen Bitmap and its window is hardware accelerated, Canvas.isHardwareAccelerated() will likely return false, and this method will return true.

        Returns:
        True if the view is attached to a window and the window is hardware accelerated; false in any other case.
      • draw

        public void draw(Canvas canvas)
        Manually render this view (and all of its children) to the given Canvas. The view must have already done a full layout before this function is called. When implementing a view, implement onDraw(android.graphics.Canvas) instead of overriding this method. If you do need to override this method, call the superclass version.
        Parameters:
        canvas - The Canvas to which the View is rendered.
      • getSolidColor

        public int getSolidColor()
        Override this if your view is known to always be drawn on top of a solid color background, and needs to draw fading edges. Returning a non-zero color enables the view system to optimize the drawing of the fading edges. If you do return a non-zero color, the alpha should be set to 0xFF.
        Returns:
        The known solid color background for this view, or 0 if the color may vary
        See Also:
        setVerticalFadingEdgeEnabled(boolean), setHorizontalFadingEdgeEnabled(boolean)
      • isLayoutRequested

        public boolean isLayoutRequested()

        Indicates whether or not this view's layout will be requested during the next hierarchy layout pass.

        Returns:
        true if the layout will be forced during next layout pass
      • layout

        public void layout(int l,
                  int t,
                  int r,
                  int b)
        Assign a size and position to a view and all of its descendants

        This is the second phase of the layout mechanism. (The first is measuring). In this phase, each parent calls layout on all of its children to position them. This is typically done using the child measurements that were stored in the measure pass().

        Derived classes should not override this method. Derived classes with children should override onLayout. In that method, they should call layout on each of their children.

        Parameters:
        l - Left position, relative to parent
        t - Top position, relative to parent
        r - Right position, relative to parent
        b - Bottom position, relative to parent
      • onLayout

        protected void onLayout(boolean changed,
                    int left,
                    int top,
                    int right,
                    int bottom)
        Called from layout when this view should assign a size and position to each of its children. Derived classes with children should override this method and call layout on each of their children.
        Parameters:
        changed - This is a new size or position for this view
        left - Left position, relative to parent
        top - Top position, relative to parent
        right - Right position, relative to parent
        bottom - Bottom position, relative to parent
      • setFrame

        protected boolean setFrame(int left,
                       int top,
                       int right,
                       int bottom)
        Assign a size and position to this view. This is called from layout.
        Parameters:
        left - Left position, relative to parent
        top - Top position, relative to parent
        right - Right position, relative to parent
        bottom - Bottom position, relative to parent
        Returns:
        true if the new size and position are different than the previous ones
      • onFinishInflate

        protected void onFinishInflate()
        Finalize inflating a view from XML. This is called as the last phase of inflation, after all child views have been added.

        Even if the subclass overrides onFinishInflate, they should always be sure to call the super method, so that we get called.

      • getResources

        public Resources getResources()
        Returns the resources associated with this view.
        Returns:
        Resources object.
      • invalidateDrawable

        public void invalidateDrawable(Drawable drawable)
        Invalidates the specified Drawable.
        Specified by:
        invalidateDrawable in interface Drawable.Callback
        Parameters:
        drawable - the drawable to invalidate
      • scheduleDrawable

        public void scheduleDrawable(Drawable who,
                            Runnable what,
                            long when)
        Schedules an action on a drawable to occur at a specified time.
        Specified by:
        scheduleDrawable in interface Drawable.Callback
        Parameters:
        who - the recipient of the action
        what - the action to run on the drawable
        when - the time at which the action must occur. Uses the SystemClock.uptimeMillis() timebase.
      • unscheduleDrawable

        public void unscheduleDrawable(Drawable who,
                              Runnable what)
        Cancels a scheduled action on a drawable.
        Specified by:
        unscheduleDrawable in interface Drawable.Callback
        Parameters:
        who - the recipient of the action
        what - the action to cancel
      • unscheduleDrawable

        public void unscheduleDrawable(Drawable who)
        Unschedule any events associated with the given Drawable. This can be used when selecting a new Drawable into a view, so that the previous one is completely unscheduled.
        Parameters:
        who - The Drawable to unschedule.
        See Also:
        drawableStateChanged()
      • resolveDrawables

        protected void resolveDrawables()
        Resolve the Drawables depending on the layout direction. This is implicitly supposing that the View directionality can and will be resolved before its Drawables. Will call onResolveDrawables(int) when resolution is done.
      • onResolveDrawables

        public void onResolveDrawables(int layoutDirection)
        Called when layout direction has been resolved. The default implementation does nothing.
        Parameters:
        layoutDirection - The resolved layout direction.
        See Also:
        LAYOUT_DIRECTION_LTR, LAYOUT_DIRECTION_RTL
      • resetResolvedDrawables

        protected void resetResolvedDrawables()
      • verifyDrawable

        protected boolean verifyDrawable(Drawable who)
        If your view subclass is displaying its own Drawable objects, it should override this function and return true for any Drawable it is displaying. This allows animations for those drawables to be scheduled.

        Be sure to call through to the super class when overriding this function.

        Parameters:
        who - The Drawable to verify. Return true if it is one you are displaying, else return the result of calling through to the super class.
        Returns:
        boolean If true than the Drawable is being displayed in the view; else false and it is not allowed to animate.
        See Also:
        unscheduleDrawable(android.graphics.drawable.Drawable), drawableStateChanged()
      • drawableStateChanged

        protected void drawableStateChanged()
        This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

        Be sure to call through to the superclass when overriding this function.

        See Also:
        Drawable.setState(int[])
      • refreshDrawableState

        public void refreshDrawableState()
        Call this to force a view to update its drawable state. This will cause drawableStateChanged to be called on this view. Views that are interested in the new state should call getDrawableState.
        See Also:
        drawableStateChanged(), getDrawableState()
      • onCreateDrawableState

        protected int[] onCreateDrawableState(int extraSpace)
        Generate the new Drawable state for this view. This is called by the view system when the cached Drawable state is determined to be invalid. To retrieve the current state, you should use getDrawableState().
        Parameters:
        extraSpace - if non-zero, this is the number of extra entries you would like in the returned array in which you can place your own states.
        Returns:
        Returns an array holding the current Drawable state of the view.
        See Also:
        mergeDrawableStates(int[], int[])
      • mergeDrawableStates

        protected static int[] mergeDrawableStates(int[] baseState,
                                int[] additionalState)
        Merge your own state values in additionalState into the base state values baseState that were returned by onCreateDrawableState(int).
        Parameters:
        baseState - The base state values returned by onCreateDrawableState(int), which will be modified to also hold your own additional state values.
        additionalState - The additional state values you would like added to baseState; this array is not modified.
        Returns:
        As a convenience, the baseState array you originally passed into the function is returned.
        See Also:
        onCreateDrawableState(int)
      • jumpDrawablesToCurrentState

        public void jumpDrawablesToCurrentState()
        Call Drawable.jumpToCurrentState() on all Drawable objects associated with this view.
      • setBackgroundColor

        public void setBackgroundColor(int color)
        Sets the background color for this view.
        Parameters:
        color - the color of the background
      • setBackgroundResource

        public void setBackgroundResource(int resid)
        Set the background to a given resource. The resource should refer to a Drawable object or 0 to remove the background.
        Parameters:
        resid - The identifier of the resource.
      • setBackground

        public void setBackground(Drawable background)
        Set the background to a given Drawable, or remove the background. If the background has padding, this View's padding is set to the background's padding. However, when a background is removed, this View's padding isn't touched. If setting the padding is desired, please use setPadding(int, int, int, int).
        Parameters:
        background - The Drawable to use as the background, or null to remove the background
      • getBackground

        public Drawable getBackground()
        Gets the background drawable
        Returns:
        The drawable used as the background for this view, if any.
        See Also:
        setBackground(Drawable)
      • setPadding

        public void setPadding(int left,
                      int top,
                      int right,
                      int bottom)
        Sets the padding. The view may add on the space required to display the scrollbars, depending on the style and visibility of the scrollbars. So the values returned from getPaddingLeft(), getPaddingTop(), getPaddingRight() and getPaddingBottom() may be different from the values set in this call.
        Parameters:
        left - the left padding in pixels
        top - the top padding in pixels
        right - the right padding in pixels
        bottom - the bottom padding in pixels
      • internalSetPadding

        protected void internalSetPadding(int left,
                              int top,
                              int right,
                              int bottom)
      • setPaddingRelative

        public void setPaddingRelative(int start,
                              int top,
                              int end,
                              int bottom)
        Sets the relative padding. The view may add on the space required to display the scrollbars, depending on the style and visibility of the scrollbars. So the values returned from getPaddingStart(), getPaddingTop(), getPaddingEnd() and getPaddingBottom() may be different from the values set in this call.
        Parameters:
        start - the start padding in pixels
        top - the top padding in pixels
        end - the end padding in pixels
        bottom - the bottom padding in pixels
      • getPaddingTop

        public int getPaddingTop()
        Returns the top padding of this view.
        Returns:
        the top padding in pixels
      • getPaddingBottom

        public int getPaddingBottom()
        Returns the bottom padding of this view. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well.
        Returns:
        the bottom padding in pixels
      • getPaddingLeft

        public int getPaddingLeft()
        Returns the left padding of this view. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well.
        Returns:
        the left padding in pixels
      • getPaddingStart

        public int getPaddingStart()
        Returns the start padding of this view depending on its resolved layout direction. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well.
        Returns:
        the start padding in pixels
      • getPaddingRight

        public int getPaddingRight()
        Returns the right padding of this view. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well.
        Returns:
        the right padding in pixels
      • getPaddingEnd

        public int getPaddingEnd()
        Returns the end padding of this view depending on its resolved layout direction. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well.
        Returns:
        the end padding in pixels
      • isPaddingRelative

        public boolean isPaddingRelative()
        Return if the padding as been set thru relative values setPaddingRelative(int, int, int, int) or thru
        Returns:
        true if the padding is relative or false if it is not.
      • resetPaddingToInitialValues

        public void resetPaddingToInitialValues()
      • getOpticalInsets

        public Insets getOpticalInsets()
      • setLayoutInsets

        public void setLayoutInsets(Insets layoutInsets)
      • setSelected

        public void setSelected(boolean selected)
        Changes the selection state of this view. A view can be selected or not. Note that selection is not the same as focus. Views are typically selected in the context of an AdapterView like ListView or GridView; the selected view is the view that is highlighted.
        Parameters:
        selected - true if the view must be selected, false otherwise
      • dispatchSetSelected

        protected void dispatchSetSelected(boolean selected)
        Dispatch setSelected to all of this View's children.
        Parameters:
        selected - The new selected state
        See Also:
        setSelected(boolean)
      • isSelected

        public boolean isSelected()
        Indicates the selection state of this view.
        Returns:
        true if the view is selected, false otherwise
      • setActivated

        public void setActivated(boolean activated)
        Changes the activated state of this view. A view can be activated or not. Note that activation is not the same as selection. Selection is a transient property, representing the view (hierarchy) the user is currently interacting with. Activation is a longer-term state that the user can move views in and out of. For example, in a list view with single or multiple selection enabled, the views in the current selection set are activated. (Um, yeah, we are deeply sorry about the terminology here.) The activated state is propagated down to children of the view it is set on.
        Parameters:
        activated - true if the view must be activated, false otherwise
      • dispatchSetActivated

        protected void dispatchSetActivated(boolean activated)
        Dispatch setActivated to all of this View's children.
        Parameters:
        activated - The new activated state
        See Also:
        setActivated(boolean)
      • isActivated

        public boolean isActivated()
        Indicates the activation state of this view.
        Returns:
        true if the view is activated, false otherwise
      • getViewTreeObserver

        public ViewTreeObserver getViewTreeObserver()
        Returns the ViewTreeObserver for this view's hierarchy. The view tree observer can be used to get notifications when global events, like layout, happen. The returned ViewTreeObserver observer is not guaranteed to remain valid for the lifetime of this View. If the caller of this method keeps a long-lived reference to ViewTreeObserver, it should always check for the return value of ViewTreeObserver.isAlive().
        Returns:
        The ViewTreeObserver for this view's hierarchy.
      • getRootView

        public View getRootView()

        Finds the topmost view in the current view hierarchy.

        Returns:
        the topmost view containing this view
      • getLocationOnScreen

        public void getLocationOnScreen(int[] location)

        Computes the coordinates of this view on the screen. The argument must be an array of two integers. After the method returns, the array contains the x and y location in that order.

        Parameters:
        location - an array of two integers in which to hold the coordinates
      • getLocationInWindow

        public void getLocationInWindow(int[] location)

        Computes the coordinates of this view in its window. The argument must be an array of two integers. After the method returns, the array contains the x and y location in that order.

        Parameters:
        location - an array of two integers in which to hold the coordinates
      • findViewTraversal

        protected View findViewTraversal(int id)
        Parameters:
        id - the id of the view to be found
        Returns:
        the view of the specified id, null if cannot be found
      • findViewWithTagTraversal

        protected View findViewWithTagTraversal(Object tag)
        Parameters:
        tag - the tag of the view to be found
        Returns:
        the view of specified tag, null if cannot be found
      • findViewByPredicateTraversal

        protected View findViewByPredicateTraversal(com.android.internal.util.Predicate<View> predicate,
                                        View childToSkip)
        Parameters:
        predicate - The predicate to evaluate.
        childToSkip - If not null, ignores this child during the recursive traversal.
        Returns:
        The first view that matches the predicate or null.
      • findViewById

        public final View findViewById(int id)
        Look for a child view with the given id. If this view has the given id, return this view.
        Parameters:
        id - The id to search for.
        Returns:
        The view that has the given id in the hierarchy or null
      • findViewWithTag

        public final View findViewWithTag(Object tag)
        Look for a child view with the given tag. If this view has the given tag, return this view.
        Parameters:
        tag - The tag to search for, using "tag.equals(getTag())".
        Returns:
        The View that has the given tag in the hierarchy or null
      • findViewByPredicate

        public final View findViewByPredicate(com.android.internal.util.Predicate<View> predicate)
        Look for a child view that matches the specified predicate. If this view matches the predicate, return this view.
        Parameters:
        predicate - The predicate to evaluate.
        Returns:
        The first view that matches the predicate or null.
      • findViewByPredicateInsideOut

        public final View findViewByPredicateInsideOut(View start,
                                        com.android.internal.util.Predicate<View> predicate)
        Look for a child view that matches the specified predicate, starting with the specified view and its descendents and then recusively searching the ancestors and siblings of that view until this view is reached. This method is useful in cases where the predicate does not match a single unique view (perhaps multiple views use the same id) and we are trying to find the view that is "closest" in scope to the starting view.
        Parameters:
        start - The view to start from.
        predicate - The predicate to evaluate.
        Returns:
        The first view that matches the predicate or null.
      • setId

        public void setId(int id)
        Sets the identifier for this view. The identifier does not have to be unique in this view's hierarchy. The identifier should be a positive number.
        Parameters:
        id - a number used to identify the view
        See Also:
        NO_ID, getId(), findViewById(int)
      • setIsRootNamespace

        public void setIsRootNamespace(boolean isRoot)
        Parameters:
        isRoot - true if the view belongs to the root namespace, false otherwise
      • isRootNamespace

        public boolean isRootNamespace()
        Returns:
        true if the view belongs to the root namespace, false otherwise
      • getId

        public int getId()
        Returns this view's identifier.
        Returns:
        a positive integer used to identify the view or NO_ID if the view has no ID
        See Also:
        setId(int), findViewById(int)
      • setTag

        public void setTag(Object tag)
        Sets the tag associated with this view. A tag can be used to mark a view in its hierarchy and does not have to be unique within the hierarchy. Tags can also be used to store data within a view without resorting to another data structure.
        Parameters:
        tag - an Object to tag the view with
        See Also:
        getTag(), setTag(int, Object)
      • getTag

        public Object getTag(int key)
        Returns the tag associated with this view and the specified key.
        Parameters:
        key - The key identifying the tag
        Returns:
        the Object stored in this view as a tag
        See Also:
        setTag(int, Object), getTag()
      • setTag

        public void setTag(int key,
                  Object tag)
        Sets a tag associated with this view and a key. A tag can be used to mark a view in its hierarchy and does not have to be unique within the hierarchy. Tags can also be used to store data within a view without resorting to another data structure. The specified key should be an id declared in the resources of the application to ensure it is unique (see the ID resource type). Keys identified as belonging to the Android framework or not associated with any package will cause an IllegalArgumentException to be thrown.
        Parameters:
        key - The key identifying the tag
        tag - An Object to tag the view with
        Throws:
        IllegalArgumentException - If they specified key is not valid
        See Also:
        setTag(Object), getTag(int)
      • setTagInternal

        public void setTagInternal(int key,
                          Object tag)
        Variation of setTag(int, Object) that enforces the key to be a framework id.
      • debug

        public void debug()
        Prints information about this view in the log output, with the tag VIEW_LOG_TAG.
      • debug

        protected void debug(int depth)
        Prints information about this view in the log output, with the tag VIEW_LOG_TAG. Each line in the output is preceded with an indentation defined by the depth.
        Parameters:
        depth - the indentation level
      • debugIndent

        protected static String debugIndent(int depth)
        Creates a string of whitespaces used for indentation.
        Parameters:
        depth - the indentation level
        Returns:
        a String containing (depth * 2 + 3) * 2 white spaces
      • getBaseline

        public int getBaseline()

        Return the offset of the widget's text baseline from the widget's top boundary. If this widget does not support baseline alignment, this method returns -1.

        Returns:
        the offset of the baseline within the widget's bounds or -1 if baseline alignment is not supported
      • requestLayout

        public void requestLayout()
        Call this when something has changed which has invalidated the layout of this view. This will schedule a layout pass of the view tree.
      • forceLayout

        public void forceLayout()
        Forces this view to be laid out during the next layout pass. This method does not call requestLayout() or forceLayout() on the parent.
      • measure

        public final void measure(int widthMeasureSpec,
                   int heightMeasureSpec)

        This is called to find out how big a view should be. The parent supplies constraint information in the width and height parameters.

        The actual measurement work of a view is performed in onMeasure(int, int), called by this method. Therefore, only onMeasure(int, int) can and must be overridden by subclasses.

        Parameters:
        widthMeasureSpec - Horizontal space requirements as imposed by the parent
        heightMeasureSpec - Vertical space requirements as imposed by the parent
        See Also:
        onMeasure(int, int)
      • setMeasuredDimension

        protected final void setMeasuredDimension(int measuredWidth,
                                int measuredHeight)

        This mehod must be called by onMeasure(int, int) to store the measured width and measured height. Failing to do so will trigger an exception at measurement time.

        Parameters:
        measuredWidth - The measured width of this view. May be a complex bit mask as defined by MEASURED_SIZE_MASK and MEASURED_STATE_TOO_SMALL.
        measuredHeight - The measured height of this view. May be a complex bit mask as defined by MEASURED_SIZE_MASK and MEASURED_STATE_TOO_SMALL.
      • combineMeasuredStates

        public static int combineMeasuredStates(int curState,
                                int newState)
        Merge two states as returned by getMeasuredState().
        Parameters:
        curState - The current state as returned from a view or the result of combining multiple views.
        newState - The new view state to combine.
        Returns:
        Returns a new integer reflecting the combination of the two states.
      • resolveSizeAndState

        public static int resolveSizeAndState(int size,
                              int measureSpec,
                              int childMeasuredState)
        Utility to reconcile a desired size and state, with constraints imposed by a MeasureSpec. Will take the desired size, unless a different size is imposed by the constraints. The returned value is a compound integer, with the resolved size in the MEASURED_SIZE_MASK bits and optionally the bit MEASURED_STATE_TOO_SMALL set if the resulting size is smaller than the size the view wants to be.
        Parameters:
        size - How big the view wants to be
        measureSpec - Constraints imposed by the parent
        Returns:
        Size information bit mask as defined by MEASURED_SIZE_MASK and MEASURED_STATE_TOO_SMALL.
      • getDefaultSize

        public static int getDefaultSize(int size,
                         int measureSpec)
        Utility to return a default size. Uses the supplied size if the MeasureSpec imposed no constraints. Will get larger if allowed by the MeasureSpec.
        Parameters:
        size - Default size for this view
        measureSpec - Constraints imposed by the parent
        Returns:
        The size this view should be.
      • getSuggestedMinimumHeight

        protected int getSuggestedMinimumHeight()
        Returns the suggested minimum height that the view should use. This returns the maximum of the view's minimum height and the background's minimum height (Drawable.getMinimumHeight()).

        When being used in onMeasure(int, int), the caller should still ensure the returned height is within the requirements of the parent.

        Returns:
        The suggested minimum height of the view.
      • getSuggestedMinimumWidth

        protected int getSuggestedMinimumWidth()
        Returns the suggested minimum width that the view should use. This returns the maximum of the view's minimum width) and the background's minimum width (Drawable.getMinimumWidth()).

        When being used in onMeasure(int, int), the caller should still ensure the returned width is within the requirements of the parent.

        Returns:
        The suggested minimum width of the view.
      • getMinimumHeight

        public int getMinimumHeight()
        Returns the minimum height of the view.
        Returns:
        the minimum height the view will try to be.
        See Also:
        setMinimumHeight(int)
      • setMinimumHeight

        public void setMinimumHeight(int minHeight)
        Sets the minimum height of the view. It is not guaranteed the view will be able to achieve this minimum height (for example, if its parent layout constrains it with less available height).
        Parameters:
        minHeight - The minimum height the view will try to be.
        See Also:
        getMinimumHeight()
      • getMinimumWidth

        public int getMinimumWidth()
        Returns the minimum width of the view.
        Returns:
        the minimum width the view will try to be.
        See Also:
        setMinimumWidth(int)
      • setMinimumWidth

        public void setMinimumWidth(int minWidth)
        Sets the minimum width of the view. It is not guaranteed the view will be able to achieve this minimum width (for example, if its parent layout constrains it with less available width).
        Parameters:
        minWidth - The minimum width the view will try to be.
        See Also:
        getMinimumWidth()
      • getAnimation

        public Animation getAnimation()
        Get the animation currently associated with this view.
        Returns:
        The animation that is currently playing or scheduled to play for this view.
      • startAnimation

        public void startAnimation(Animation animation)
        Start the specified animation now.
        Parameters:
        animation - the animation to start now
      • clearAnimation

        public void clearAnimation()
        Cancels any animations for this view.
      • setAnimation

        public void setAnimation(Animation animation)
        Sets the next animation to play for this view. If you want the animation to play immediately, use startAnimation(android.view.animation.Animation) instead. This method provides allows fine-grained control over the start time and invalidation, but you must make sure that 1) the animation has a start time set, and 2) the view's parent (which controls animations on its children) will be invalidated when the animation is supposed to start.
        Parameters:
        animation - The next animation, or null.
      • onSetAlpha

        protected boolean onSetAlpha(int alpha)
        Invoked if there is a Transform that involves alpha. Subclass that can draw themselves with the specified alpha should return true, and then respect that alpha when their onDraw() is called. If this returns false then the view may be redirected to draw into an offscreen buffer to fulfill the request, which will look fine, but may be slower than if the subclass handles it internally. The default implementation returns false.
        Parameters:
        alpha - The alpha (0..255) to apply to the view's drawing
        Returns:
        true if the view can draw with the specified alpha.
      • gatherTransparentRegion

        public boolean gatherTransparentRegion(Region region)
        This is used by the RootView to perform an optimization when the view hierarchy contains one or several SurfaceView. SurfaceView is always considered transparent, but its children are not, therefore all View objects remove themselves from the global transparent region (passed as a parameter to this function).
        Parameters:
        region - The transparent region for this ViewAncestor (window).
        Returns:
        Returns true if the effective visibility of the view at this point is opaque, regardless of the transparent region; returns false if it is possible for underlying windows to be seen behind the view.
      • playSoundEffect

        public void playSoundEffect(int soundConstant)
        Play a sound effect for this view.

        The framework will play sound effects for some built in actions, such as clicking, but you may wish to play these effects in your widget, for instance, for internal navigation.

        The sound effect will only be played if sound effects are enabled by the user, and isSoundEffectsEnabled() is true.

        Parameters:
        soundConstant - One of the constants defined in SoundEffectConstants
      • performHapticFeedback

        public boolean performHapticFeedback(int feedbackConstant)
        BZZZTT!!1!

        Provide haptic feedback to the user for this view.

        The framework will provide haptic feedback for some built in actions, such as long presses, but you may wish to provide feedback for your own widget.

        The feedback will only be performed if isHapticFeedbackEnabled() is true.

        Parameters:
        feedbackConstant - One of the constants defined in HapticFeedbackConstants
      • setSystemUiVisibility

        public void setSystemUiVisibility(int visibility)
        Request that the visibility of the status bar or other screen/window decorations be changed.

        This method is used to put the over device UI into temporary modes where the user's attention is focused more on the application content, by dimming or hiding surrounding system affordances. This is typically used in conjunction with Window.FEATURE_ACTION_BAR_OVERLAY, allowing the applications content to be placed behind the action bar (and with these flags other system affordances) so that smooth transitions between hiding and showing them can be done.

        Two representative examples of the use of system UI visibility is implementing a content browsing application (like a magazine reader) and a video playing application.

        The first code shows a typical implementation of a View in a content browsing application. In this implementation, the application goes into a content-oriented mode by hiding the status bar and action bar, and putting the navigation elements into lights out mode. The user can then interact with content while in this mode. Such an application should provide an easy way for the user to toggle out of the mode (such as to check information in the status bar or access notifications). In the implementation here, this is done simply by tapping on the content.

        This second code sample shows a typical implementation of a View in a video playing application. In this situation, while the video is playing the application would like to go into a complete full-screen mode, to use as much of the display as possible for the video. When in this state the user can not interact with the application; the system intercepts touching on the screen to pop the UI out of full screen mode. See fitSystemWindows(Rect) for a sample layout that goes with this code.

        Parameters:
        visibility - Bitwise-or of flags SYSTEM_UI_FLAG_LOW_PROFILE, SYSTEM_UI_FLAG_HIDE_NAVIGATION, SYSTEM_UI_FLAG_FULLSCREEN, SYSTEM_UI_FLAG_LAYOUT_STABLE, SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION, and SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN.
      • getWindowSystemUiVisibility

        public int getWindowSystemUiVisibility()
        Returns the current system UI visibility that is currently set for the entire window. This is the combination of the setSystemUiVisibility(int) values supplied by all of the views in the window.
      • dispatchWindowSystemUiVisiblityChanged

        public void dispatchWindowSystemUiVisiblityChanged(int visible)
        Dispatch callbacks to onWindowSystemUiVisibilityChanged(int) down the view hierarchy.
      • setDisabledSystemUiVisibility

        public void setDisabledSystemUiVisibility(int flags)
      • startDrag

        public final boolean startDrag(ClipData data,
                        View.DragShadowBuilder shadowBuilder,
                        Object myLocalState,
                        int flags)
        Starts a drag and drop operation. When your application calls this method, it passes a View.DragShadowBuilder object to the system. The system calls this object's View.DragShadowBuilder.onProvideShadowMetrics(Point, Point) to get metrics for the drag shadow, and then calls the object's View.DragShadowBuilder.onDrawShadow(Canvas) to draw the drag shadow itself.

        Once the system has the drag shadow, it begins the drag and drop operation by sending drag events to all the View objects in your application that are currently visible. It does this either by calling the View object's drag listener (an implementation of onDrag() or by calling the View object's onDragEvent() method. Both are passed a DragEvent object that has a DragEvent.getAction() value of DragEvent.ACTION_DRAG_STARTED.

        Your application can invoke startDrag() on any attached View object. The View object does not need to be the one used in View.DragShadowBuilder, nor does it need to be related to the View the user selected for dragging.

        Parameters:
        data - A ClipData object pointing to the data to be transferred by the drag and drop operation.
        shadowBuilder - A View.DragShadowBuilder object for building the drag shadow.
        myLocalState - An Object containing local data about the drag and drop operation. This Object is put into every DragEvent object sent by the system during the current drag.

        myLocalState is a lightweight mechanism for the sending information from the dragged View to the target Views. For example, it can contain flags that differentiate between a a copy operation and a move operation.

        flags - Flags that control the drag and drop operation. No flags are currently defined, so the parameter should be set to 0.
        Returns:
        true if the method completes successfully, or false if it fails anywhere. Returning false means the system was unable to do a drag, and so no drag operation is in progress.
      • onDragEvent

        public boolean onDragEvent(DragEvent event)
        Handles drag events sent by the system following a call to startDrag().

        When the system calls this method, it passes a DragEvent object. A call to DragEvent.getAction() returns one of the action type constants defined in DragEvent. The method uses these to determine what is happening in the drag and drop operation.

        Parameters:
        event - The DragEvent sent by the system. The DragEvent.getAction() method returns an action type constant defined in DragEvent, indicating the type of drag event represented by this object.
        Returns:
        true if the method was successful, otherwise false.

        The method should return true in response to an action type of DragEvent.ACTION_DRAG_STARTED to receive drag events for the current operation.

        The method should also return true in response to an action type of DragEvent.ACTION_DROP if it consumed the drop, or false if it didn't.

      • dispatchDragEvent

        public boolean dispatchDragEvent(DragEvent event)
        Detects if this View is enabled and has a drag event listener. If both are true, then it calls the drag event listener with the DragEvent it received. If the drag event listener returns true, then dispatchDragEvent() returns true.

        For all other cases, the method calls the onDragEvent() drag event handler method and returns its result.

        This ensures that a drag event is always consumed, even if the View does not have a drag event listener. However, if the View has a listener and the listener returns true, then onDragEvent() is not called.

      • onCloseSystemDialogs

        public void onCloseSystemDialogs(String reason)
        This needs to be a better API (NOT ON VIEW) before it is exposed. If it is ever exposed at all.
      • applyDrawableToTransparentRegion

        public void applyDrawableToTransparentRegion(Drawable dr,
                                            Region region)
        Given a Drawable whose bounds have been set to draw into this view, update a Region being computed for gatherTransparentRegion(android.graphics.Region) so that any non-transparent parts of the Drawable are removed from the given transparent region.
        Parameters:
        dr - The Drawable whose transparency is to be applied to the region.
        region - A Region holding the current transparency information, where any parts of the region that are set are considered to be transparent. On return, this region will be modified to have the transparency information reduced by the corresponding parts of the Drawable that are not transparent.
      • inflate

        public static View inflate(Context context,
                   int resource,
                   ViewGroup root)
        Inflate a view from an XML resource. This convenience method wraps the LayoutInflater class, which provides a full range of options for view inflation.
        Parameters:
        context - The Context object for your activity or application.
        resource - The resource ID to inflate
        root - A view group that will be the parent. Used to properly inflate the layout_* parameters.
        See Also:
        LayoutInflater
      • overScrollBy

        protected boolean overScrollBy(int deltaX,
                           int deltaY,
                           int scrollX,
                           int scrollY,
                           int scrollRangeX,
                           int scrollRangeY,
                           int maxOverScrollX,
                           int maxOverScrollY,
                           boolean isTouchEvent)
        Scroll the view with standard behavior for scrolling beyond the normal content boundaries. Views that call this method should override onOverScrolled(int, int, boolean, boolean) to respond to the results of an over-scroll operation. Views can use this method to handle any touch or fling-based scrolling.
        Parameters:
        deltaX - Change in X in pixels
        deltaY - Change in Y in pixels
        scrollX - Current X scroll value in pixels before applying deltaX
        scrollY - Current Y scroll value in pixels before applying deltaY
        scrollRangeX - Maximum content scroll range along the X axis
        scrollRangeY - Maximum content scroll range along the Y axis
        maxOverScrollX - Number of pixels to overscroll by in either direction along the X axis.
        maxOverScrollY - Number of pixels to overscroll by in either direction along the Y axis.
        isTouchEvent - true if this scroll operation is the result of a touch event.
        Returns:
        true if scrolling was clamped to an over-scroll boundary along either axis, false otherwise.
      • onOverScrolled

        protected void onOverScrolled(int scrollX,
                          int scrollY,
                          boolean clampedX,
                          boolean clampedY)
        Called by overScrollBy(int, int, int, int, int, int, int, int, boolean) to respond to the results of an over-scroll operation.
        Parameters:
        scrollX - New X scroll value in pixels
        scrollY - New Y scroll value in pixels
        clampedX - True if scrollX was clamped to an over-scroll boundary
        clampedY - True if scrollY was clamped to an over-scroll boundary
      • setOverScrollMode

        public void setOverScrollMode(int overScrollMode)
        Set the over-scroll mode for this view. Valid over-scroll modes are OVER_SCROLL_ALWAYS (default), OVER_SCROLL_IF_CONTENT_SCROLLS (allow over-scrolling only if the view content is larger than the container), or OVER_SCROLL_NEVER. Setting the over-scroll mode of a view will have an effect only if the view is capable of scrolling.
        Parameters:
        overScrollMode - The new over-scroll mode for this view.
      • getVerticalScrollFactor

        protected float getVerticalScrollFactor()
        Gets a scale factor that determines the distance the view should scroll vertically in response to MotionEvent.ACTION_SCROLL.
        Returns:
        The vertical scroll scale factor.
      • getHorizontalScrollFactor

        protected float getHorizontalScrollFactor()
        Gets a scale factor that determines the distance the view should scroll horizontally in response to MotionEvent.ACTION_SCROLL.
        Returns:
        The horizontal scroll scale factor.
      • resolveTextDirection

        public boolean resolveTextDirection()
        Resolve the text direction.
        Returns:
        true if resolution has been done, false otherwise.
      • resetResolvedTextDirection

        public void resetResolvedTextDirection()
        Reset resolved text direction. Text direction will be resolved during a call to onMeasure(int, int).
      • isTextDirectionInherited

        public boolean isTextDirectionInherited()
        Returns:
        true if text direction is inherited.
      • resolveTextAlignment

        public boolean resolveTextAlignment()
        Resolve the text alignment.
        Returns:
        true if resolution has been done, false otherwise.
      • resetResolvedTextAlignment

        public void resetResolvedTextAlignment()
        Reset resolved text alignment. Text alignment will be resolved during a call to onMeasure(int, int).
      • isTextAlignmentInherited

        public boolean isTextAlignmentInherited()
        Returns:
        true if text alignment is inherited.
      • generateViewId

        public static int generateViewId()
        Generate a value suitable for use in setId(int). This value will not collide with ID values generated at build time by aapt for R.id.
        Returns:
        a generated ID value
      • hackTurnOffWindowResizeAnim

        public void hackTurnOffWindowResizeAnim(boolean off)
      • animate

        public ViewPropertyAnimator animate()
        This method returns a ViewPropertyAnimator object, which can be used to animate specific properties on this View.
        Returns:
        ViewPropertyAnimator The ViewPropertyAnimator associated with this View.


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: 307 / . Delta: 0.28627 с