java.lang.Object | |
↳ | android.view.View |
Known Direct Subclasses |
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.
For an introduction to using this class to develop your
application's user interface, read the Developer Guide documentation on
User Interface. Special topics
include:
Declaring Layout
Creating Menus
Common Layout Objects
Binding to Data with AdapterView
Handling UI Events
Applying Styles and Themes
Building Custom Components
How Android Draws 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:
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.
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(Canvas) |
Called when the view should render its content. |
Event processing | onKeyDown(int, KeyEvent) |
Called when a new key event occurs. |
onKeyUp(int, KeyEvent) |
Called when a 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, 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. |
<Button id="@+id/my_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/my_button_text"/>
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.
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.)
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) method and queried by calling getPaddingLeft(), getPaddingTop(), getPaddingRight() and getPaddingBottom().
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 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:
MeasureSpecs are used to push requirements down the tree from parent to child. A MeasureSpec can be in one of three modes:
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 is handled by walking the tree and rendering each view that
intersects the 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().
The basic cycle of a view is as follows:
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.
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().
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.
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) for more details.
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.
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.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
View.BaseSavedState | Base class for derived classes that want to save and restore their own state in onSaveInstanceState(). | ||||||||||
View.MeasureSpec | A MeasureSpec encapsulates the layout requirements passed from parent to child. | ||||||||||
View.OnClickListener | Interface definition for a callback to be invoked when a view is clicked. | ||||||||||
View.OnCreateContextMenuListener | Interface definition for a callback to be invoked when the context menu for this view is being built. | ||||||||||
View.OnFocusChangeListener | Interface definition for a callback to be invoked when the focus state of a view changed. | ||||||||||
View.OnKeyListener | Interface definition for a callback to be invoked when a key event is dispatched to this view. | ||||||||||
View.OnLongClickListener | Interface definition for a callback to be invoked when a view has been clicked and held. | ||||||||||
View.OnTouchListener | Interface definition for a callback to be invoked when a touch event is dispatched to this view. |
XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
android:background | setBackgroundResource(int) | A drawable to use as the background. | |||||||||
android:clickable | setClickable(boolean) | Defines whether this view reacts to click events. | |||||||||
android:drawingCacheQuality | setDrawingCacheQuality(int) | Defines the quality of translucent drawing caches. | |||||||||
android:fadingEdge | setVerticalFadingEdgeEnabled(boolean) | Defines which edges should be fadeded on scrolling. | |||||||||
android:fadingEdgeLength | getVerticalFadingEdgeLength() | Defines the length of the fading edges. | |||||||||
android:fitsSystemWindows | Boolean internal attribute to adjust view layout based on system windows such as the status bar. | ||||||||||
android:focusable | setFocusable(boolean) | Boolean that controls whether a view can take focus. | |||||||||
android:focusableInTouchMode | setFocusableInTouchMode(boolean) | Boolean that controls whether a view can take focus while in touch mode. | |||||||||
android:hapticFeedbackEnabled | setHapticFeedbackEnabled(boolean) | Boolean that controls whether a view should have haptic feedback enabled for events such as long presses. | |||||||||
android:id | setId(int) | Supply an identifier name for this view, to later retrieve it with View.findViewById() or Activity.findViewById(). | |||||||||
android:keepScreenOn | setKeepScreenOn(boolean) | Controls whether the view's window should keep the screen on while visible. | |||||||||
android:longClickable | setLongClickable(boolean) | Defines whether this view reacts to long click events. | |||||||||
android:nextFocusDown | setNextFocusDownId(int) | Defines the next view to give focus to when the next focus is FOCUS_DOWN If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a RuntimeException will result when the reference is accessed. | |||||||||
android:nextFocusLeft | setNextFocusLeftId(int) | Defines the next view to give focus to when the next focus is FOCUS_LEFT. | |||||||||
android:nextFocusRight | setNextFocusRightId(int) | Defines the next view to give focus to when the next focus is FOCUS_RIGHT If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a RuntimeException will result when the reference is accessed. | |||||||||
android:nextFocusUp | setNextFocusUpId(int) | Defines the next view to give focus to when the next focus is FOCUS_UP If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a RuntimeException will result when the reference is accessed. | |||||||||
android:padding | setPadding(int,int,int,int) | Sets the padding, in pixels, of all four edges. | |||||||||
android:paddingBottom | setPadding(int,int,int,int) | Sets the padding, in pixels, of the bottom edge; see padding. | |||||||||
android:paddingLeft | setPadding(int,int,int,int) | Sets the padding, in pixels, of the left edge; see padding. | |||||||||
android:paddingRight | setPadding(int,int,int,int) | Sets the padding, in pixels, of the right edge; see padding. | |||||||||
android:paddingTop | setPadding(int,int,int,int) | Sets the padding, in pixels, of the top edge; see padding. | |||||||||
android:saveEnabled | setSaveEnabled(boolean) | If unset, no state will be saved for this view when it is being frozen. | |||||||||
android:scrollX | The initial horizontal scroll offset, in pixels. | ||||||||||
android:scrollY | The initial vertical scroll offset, in pixels. | ||||||||||
android:scrollbarAlwaysDrawHorizontalTrack | Defines whether the horizontal scrollbar track should always be drawn. | ||||||||||
android:scrollbarAlwaysDrawVerticalTrack | Defines whether the vertical scrollbar track should always be drawn
Must be a boolean value, either " |
||||||||||
android:scrollbarSize | Sets the width of vertical scrollbars and height of horizontal scrollbars. | ||||||||||
android:scrollbarThumbHorizontal | Defines the horizontal scrollbar thumb drawable. | ||||||||||
android:scrollbarThumbVertical | Defines the vertical scrollbar thumb drawable. | ||||||||||
android:scrollbarTrackHorizontal | Defines the horizontal scrollbar track drawable. | ||||||||||
android:scrollbarTrackVertical | Defines the vertical scrollbar track drawable. | ||||||||||
android:scrollbars | Defines which scrollbars should be displayed on scrolling or not. | ||||||||||
android:soundEffectsEnabled | setSoundEffectsEnabled(boolean) | Boolean that controls whether a view should have sound effects enabled for events such as clicking and touching. | |||||||||
android:visibility | setVisibility(int) | Controls the initial visibility of the view. |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | DRAWING_CACHE_QUALITY_AUTO | Enables automatic quality mode for the drawing cache. |
|||||||||
int | DRAWING_CACHE_QUALITY_HIGH | Enables high quality mode for the drawing cache. |
|||||||||
int | DRAWING_CACHE_QUALITY_LOW | Enables low quality mode for the drawing cache. |
|||||||||
int[] | EMPTY_STATE_SET | Indicates the view has no states set. | |||||||||
int[] | ENABLED_FOCUSED_SELECTED_STATE_SET | Indicates the view is enabled, focused and selected. | |||||||||
int[] | ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET | Indicates the view is enabled, focused, selected and its window has the focus. | |||||||||
int[] | ENABLED_FOCUSED_STATE_SET | Indicates the view is enabled and has the focus. | |||||||||
int[] | ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET | Indicates the view is enabled, focused and its window has the focus. | |||||||||
int[] | ENABLED_SELECTED_STATE_SET | Indicates the view is enabled and selected. | |||||||||
int[] | ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET | Indicates the view is enabled, selected and its window has the focus. | |||||||||
int[] | ENABLED_STATE_SET | Indicates the view is enabled. | |||||||||
int[] | ENABLED_WINDOW_FOCUSED_STATE_SET | Indicates the view is enabled and that its window has focus. | |||||||||
int[] | FOCUSED_SELECTED_STATE_SET | Indicates the view is focused and selected. | |||||||||
int[] | FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET | Indicates the view is focused, selected and its window has the focus. | |||||||||
int[] | FOCUSED_STATE_SET | Indicates the view is focused. | |||||||||
int[] | FOCUSED_WINDOW_FOCUSED_STATE_SET | Indicates the view has the focus and that its window has the focus. | |||||||||
int | FOCUS_BACKWARD | Use with focusSearch(int). | |||||||||
int | FOCUS_DOWN | Use with focusSearch(int). | |||||||||
int | FOCUS_FORWARD | Use with focusSearch(int). | |||||||||
int | FOCUS_LEFT | Use with focusSearch(int). | |||||||||
int | FOCUS_RIGHT | Use with focusSearch(int). | |||||||||
int | FOCUS_UP | Use with focusSearch(int). | |||||||||
int | GONE | This view is invisible, and it doesn't take any space for layout purposes. | |||||||||
int | HAPTIC_FEEDBACK_ENABLED | View flag indicating whether this view should have haptic feedback enabled for events such as long presses. | |||||||||
int | INVISIBLE | This view is invisible, but it still takes up space for layout purposes. | |||||||||
int | KEEP_SCREEN_ON | View flag indicating that the screen should remain on while the window containing this view is visible to the user. | |||||||||
int | NO_ID | Used to mark a View that has no ID. | |||||||||
int[] | PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET | Indicates the view is pressed, enabled, focused and selected. | |||||||||
int[] | PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET | Indicates the view is pressed, enabled, focused, selected and its window has the focus. | |||||||||
int[] | PRESSED_ENABLED_FOCUSED_STATE_SET | Indicates the view is pressed, enabled and focused. | |||||||||
int[] | PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET | Indicates the view is pressed, enabled, focused and its window has the focus. | |||||||||
int[] | PRESSED_ENABLED_SELECTED_STATE_SET | Indicates the view is pressed, enabled and selected. | |||||||||
int[] | PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET | Indicates the view is pressed, enabled, selected and its window has the focus. | |||||||||
int[] | PRESSED_ENABLED_STATE_SET | Indicates the view is pressed and enabled. | |||||||||
int[] | PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET | Indicates the view is pressed, enabled and its window has the focus. | |||||||||
int[] | PRESSED_FOCUSED_SELECTED_STATE_SET | Indicates the view is pressed, focused and selected. | |||||||||
int[] | PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET | Indicates the view is pressed, focused, selected and its window has the focus. | |||||||||
int[] | PRESSED_FOCUSED_STATE_SET | Indicates the view is pressed and focused. | |||||||||
int[] | PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET | Indicates the view is pressed, focused and its window has the focus. | |||||||||
int[] | PRESSED_SELECTED_STATE_SET | Indicates the view is pressed and selected. | |||||||||
int[] | PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET | Indicates the view is pressed, selected and its window has the focus. | |||||||||
int[] | PRESSED_WINDOW_FOCUSED_STATE_SET | Indicates the view is pressed and its window has the focus. | |||||||||
int | SCROLLBARS_INSIDE_INSET | The scrollbar style to display the scrollbars inside the padded area, increasing the padding of the view. | |||||||||
int | SCROLLBARS_INSIDE_OVERLAY | The scrollbar style to display the scrollbars inside the content area, without increasing the padding. | |||||||||
int | SCROLLBARS_OUTSIDE_INSET | The scrollbar style to display the scrollbars at the edge of the view, increasing the padding of the view. | |||||||||
int | SCROLLBARS_OUTSIDE_OVERLAY | The scrollbar style to display the scrollbars at the edge of the view, without increasing the padding. | |||||||||
int[] | SELECTED_STATE_SET | Indicates the view is selected. | |||||||||
int[] | SELECTED_WINDOW_FOCUSED_STATE_SET | Indicates the view is selected and that its window has the focus. | |||||||||
int | SOUND_EFFECTS_ENABLED | View flag indicating whether this view should have sound effects enabled for events such as clicking and touching. | |||||||||
String | VIEW_LOG_TAG | The logging tag used by this class with android.util.Log. | |||||||||
int | VISIBLE | This view is visible. | |||||||||
int[] | WINDOW_FOCUSED_STATE_SET | Indicates the view's window has focus. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Simple constructor to use when creating a view from code.
| |||||||||||
Constructor that is called when inflating a view from XML.
| |||||||||||
Perform inflation from XML and apply a class-specific base style.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Add any focusable views that are descendants of this view (possibly
including this view if it is focusable itself) to views.
| |||||||||||
Add any touchable views that are descendants of this view (possibly
including this view if it is touchable itself) to views.
| |||||||||||
Change the view's z order in the tree, so it's on top of other sibling
views
| |||||||||||
Forces the drawing cache to be built if the drawing cache is invalid. | |||||||||||
Cancels a pending long press.
| |||||||||||
Called by the InputMethodManager
when a view who is not the current
input connection target is trying to make a call on the manager.
| |||||||||||
Cancels any animations for this view.
| |||||||||||
Called when this view wants to give up focus.
| |||||||||||
Called by a parent to request that a child update its values for mScrollX
and mScrollY if necessary.
| |||||||||||
Show the context menu for this view.
| |||||||||||
Frees the resources used by the drawing cache. | |||||||||||
Dispatch a key event to the next view on the focus path.
| |||||||||||
Dispatch a key event before it is processed by any input method
associated with the view hierarchy.
| |||||||||||
Dispatches a key shortcut event.
| |||||||||||
Pass the touch screen motion event down to the target view, or this
view if it is the target.
| |||||||||||
Pass a trackball motion event down to the focused view.
| |||||||||||
This method is the last chance for the focused view and its ancestors to
respond to an arrow key.
| |||||||||||
Called when the window containing this view gains or loses window focus.
| |||||||||||
Dispatch a window visibility change down the view hierarchy.
| |||||||||||
Manually render this view (and all of its children) to the given Canvas.
| |||||||||||
Find the view in the hierarchy rooted at this view that currently has
focus.
| |||||||||||
Look for a child view with the given id.
| |||||||||||
Look for a child view with the given tag.
| |||||||||||
Find the nearest view in the specified direction that can take focus.
| |||||||||||
Forces this view to be laid out during the next layout pass.
| |||||||||||
Get the animation currently associated with this view.
| |||||||||||
Retrieve a unique token identifying the top-level "real" window of
the window that this view is attached to.
| |||||||||||
Gets the background drawable
| |||||||||||
Return the offset of the widget's text baseline from the widget's top boundary. | |||||||||||
Bottom position of this view relative to its parent.
| |||||||||||
Returns the context the view is running in, through which it can
access the current theme, resources, etc.
| |||||||||||
Utility to return a default size.
| |||||||||||
Return an array of resource IDs of the drawable states representing the
current state of the view.
| |||||||||||
Returns the bitmap in which this view drawing is cached. | |||||||||||
Returns the quality of the drawing cache.
| |||||||||||
Return the visible drawing bounds of your view.
| |||||||||||
Return the time at which the drawing of the view hierarchy started. | |||||||||||
Find and return all focusable views that are descendants of this view,
possibly including this view if it is focusable itself.
| |||||||||||
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.
| |||||||||||
If some part of this view is not clipped by any of its parents, then
return that area in r in global (root) coordinates.
| |||||||||||
Return the height of your view.
| |||||||||||
Hit rectangle in parent's coordinates
| |||||||||||
Returns the size of the horizontal faded edges used to indicate that more
content in this view is visible.
| |||||||||||
Returns this view's identifier.
| |||||||||||
Returns whether the screen should remain on, corresponding to the current
value of KEEP_SCREEN_ON.
| |||||||||||
Get the LayoutParams associated with this view.
| |||||||||||
Left position of this view relative to its parent.
| |||||||||||
Computes the coordinates of this view in its window. | |||||||||||
Computes the coordinates of this view on the screen. | |||||||||||
The height of this view as measured in the most recent call to measure().
| |||||||||||
The width of this view as measured in the most recent call to measure().
| |||||||||||
Returns the focus-change callback registered for this view.
| |||||||||||
Returns the bottom padding of this view.
| |||||||||||
Returns the left padding of this view.
| |||||||||||
Returns the right padding of this view.
| |||||||||||
Returns the top padding of this view.
| |||||||||||
Gets the parent of this view.
| |||||||||||
Returns the resources associated with this view.
| |||||||||||
Right position of this view relative to its parent.
| |||||||||||
Finds the topmost view in the current view hierarchy. | |||||||||||
Returns the current scrollbar style. | |||||||||||
Return the scrolled left position of this view.
| |||||||||||
Return the scrolled top position of this view.
| |||||||||||
Override this if your view is known to always be drawn on top of a solid color background,
and needs to draw fading edges.
| |||||||||||
Returns this view's tag.
| |||||||||||
Top position of this view relative to its parent.
| |||||||||||
Gets the TouchDelegate for this View.
| |||||||||||
Find and return all touchable views that are descendants of this view,
possibly including this view if it is touchable itself.
| |||||||||||
Returns the size of the vertical faded edges used to indicate that more
content in this view is visible.
| |||||||||||
Returns the width of the vertical scrollbar.
| |||||||||||
Returns the ViewTreeObserver for this view's hierarchy.
| |||||||||||
Returns the visibility status for this view.
| |||||||||||
Return the width of the your view.
| |||||||||||
Retrieve a unique token identifying the window this view is attached to.
| |||||||||||
Retrieve the overall visible display size in which the window this view is
attached to has been positioned in.
| |||||||||||
Returns true if this view has focus iteself, or is the ancestor of the
view that has focus.
| |||||||||||
Returns true if this view is focusable or if it contains a reachable View
for which hasFocusable() returns true.
| |||||||||||
Returns true if this view is in a window that currently has window focus.
| |||||||||||
Inflate a view from an XML resource.
| |||||||||||
Mark the the area defined by the rect (l,t,r,b) as needing to be drawn.
| |||||||||||
Invalidate the whole view.
| |||||||||||
Mark the the area defined by dirty as needing to be drawn.
| |||||||||||
Invalidates the specified Drawable.
| |||||||||||
Indicates whether this view reacts to click events or not.
| |||||||||||
Indicates whether the drawing cache is enabled for this view. | |||||||||||
Indicates whether this duplicates its drawable state from its parent. | |||||||||||
Returns the enabled status for this view.
| |||||||||||
Returns whether this View is able to take focus.
| |||||||||||
When a view is focusable, it may not want to take focus when in touch mode.
| |||||||||||
Returns true if this view has focus
| |||||||||||
Indicate whether the horizontal edges are faded when the view is scrolled horizontally. | |||||||||||
Indicate whether the horizontal scrollbar should be drawn or not. | |||||||||||
Indicates whether this View is currently in edit mode.
| |||||||||||
Returns whether the device is currently in touch mode.
| |||||||||||
Indicates whether or not this view's layout will be requested during the next hierarchy layout pass. | |||||||||||
Indicates whether this view reacts to long click events or not.
| |||||||||||
Indicates whether the view is currently in pressed state.
| |||||||||||
Indicates whether this view will save its state (that is,
whether its onSaveInstanceState() method will be called).
| |||||||||||
Indicates the selection state of this view.
| |||||||||||
Returns the visibility of this view and all of its ancestors
| |||||||||||
Indicate whether the vertical edges are faded when the view is scrolled horizontally. | |||||||||||
Indicate whether the vertical scrollbar should be drawn or not. | |||||||||||
Assign a size and position to a view and all of its
descendants
This is the second phase of the layout mechanism. | |||||||||||
This is called to find out how big a view should be. | |||||||||||
Offset this view's horizontal location by the specified amount of pixels.
| |||||||||||
Offset this view's vertical location by the specified number of pixels.
| |||||||||||
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.
| |||||||||||
Create a new InputConnection for an InputMethod to interact
with the view.
| |||||||||||
Called after onStartTemporaryDetach() when the container is done
changing the view.
| |||||||||||
Default implementation of KeyEvent.Callback.onKeyMultiple(): perform press of the view
when KEYCODE_DPAD_CENTER or KEYCODE_ENTER
is released, if the view is enabled and clickable.
| |||||||||||
Default implementation of KeyEvent.Callback.onKeyMultiple(): always returns false (doesn't handle
the event).
| |||||||||||
Handle a key event before it is processed by any input method
associated with the view hierarchy.
| |||||||||||
Called when an unhandled key shortcut event occurs.
| |||||||||||
Default implementation of KeyEvent.Callback.onKeyMultiple(): perform clicking of the view
when KEYCODE_DPAD_CENTER or
KEYCODE_ENTER is released.
| |||||||||||
This is called when a container is going to temporarily detach a child
that currently has focus, with
ViewGroup.detachViewFromParent.
| |||||||||||
Implement this method to handle touch screen motion events.
| |||||||||||
Implement this method to handle trackball motion events.
| |||||||||||
Called when the window containing this view gains or loses focus.
| |||||||||||
Call this view's OnClickListener, if it is defined.
| |||||||||||
BZZZTT!!1!
Provide haptic feedback to the user for this view. | |||||||||||
BZZZTT!!1!
Like performHapticFeedback(int), with additional options. | |||||||||||
Call this view's OnLongClickListener, if it is defined.
| |||||||||||
Play a sound effect for this view.
| |||||||||||
Causes the Runnable to be added to the message queue.
| |||||||||||
Causes the Runnable to be added to the message queue, to be run
after the specified amount of time elapses.
| |||||||||||
Cause an invalidate to happen on a subsequent cycle through the event loop.
| |||||||||||
Cause an invalidate of the specified area to happen on a subsequent cycle
through the event loop.
| |||||||||||
Cause an invalidate to happen on a subsequent cycle through the event
loop.
| |||||||||||
Cause an invalidate of the specified area to happen on a subsequent cycle
through the event loop.
| |||||||||||
Call this to force a view to update its drawable state.
| |||||||||||
Removes the specified Runnable from the message queue.
| |||||||||||
Call this to try to give focus to a specific view or to one of its
descendants.
| |||||||||||
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.
| |||||||||||
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.
| |||||||||||
Call this to try to give focus to a specific view or to one of its descendants.
| |||||||||||
Call this when something has changed which has invalidated the
layout of this view.
| |||||||||||
Request that a rectangle of this view be visible on the screen,
scrolling if necessary just enough.
| |||||||||||
Request that a rectangle of this view be visible on the screen,
scrolling if necessary just enough.
| |||||||||||
Utility to reconcile a desired size with constraints imposed by a MeasureSpec.
| |||||||||||
Restore this view hierarchy's frozen state from the given container.
| |||||||||||
Store this view hierarchy's frozen state into the given container.
| |||||||||||
Schedules an action on a drawable to occur at a specified time.
| |||||||||||
Move the scrolled position of your view.
| |||||||||||
Set the scrolled position of your view.
| |||||||||||
Sets the next animation to play for this view.
| |||||||||||
Sets the background color for this view.
| |||||||||||
Set the background to a given Drawable, or remove the background.
| |||||||||||
Set the background to a given resource.
| |||||||||||
Enables or disables click events for this view.
| |||||||||||
Setting a solid background color for the drawing cache's bitmaps will improve
perfromance and memory usage.
| |||||||||||
Enables or disables the drawing cache. | |||||||||||
Set the drawing cache quality of this view.
| |||||||||||
Enables or disables the duplication of the parent's state into this view. | |||||||||||
Set the enabled state of this view.
| |||||||||||
Set the size of the faded edge used to indicate that more content in this
view is available.
| |||||||||||
Set whether this view can receive the focus.
| |||||||||||
Set whether this view can receive focus while in touch mode.
| |||||||||||
Set whether this view should have haptic feedback for events such as
long presses.
| |||||||||||
Define whether the horizontal edges should be faded when this view is scrolled horizontally. | |||||||||||
Define whether the horizontal scrollbar should be drawn or not. | |||||||||||
Sets the identifier for this view.
| |||||||||||
Controls whether the screen should remain on, modifying the
value of KEEP_SCREEN_ON.
| |||||||||||
Set the layout parameters associated with this view.
| |||||||||||
Enables or disables long click events for this view.
| |||||||||||
Sets the minimum height of the view.
| |||||||||||
Sets the minimum width of the view.
| |||||||||||
Set the id of the view to use for the next focus
| |||||||||||
Set the id of the view to use for the next focus
| |||||||||||
Set the id of the view to use for the next focus
| |||||||||||
Set the id of the view to use for the next focus
| |||||||||||
Register a callback to be invoked when this view is clicked.
| |||||||||||
Register a callback to be invoked when the context menu for this view is
being built.
| |||||||||||
Register a callback to be invoked when focus of this view changed.
| |||||||||||
Register a callback to be invoked when a key is pressed in this view.
| |||||||||||
Register a callback to be invoked when this view is clicked and held.
| |||||||||||
Register a callback to be invoked when a touch event is sent to this view.
| |||||||||||
Sets the padding.
| |||||||||||
Sets the pressed that for this view.
| |||||||||||
Controls whether the saving of this view's state is
enabled (that is, whether its onSaveInstanceState() method
will be called).
| |||||||||||
Specify the style of the scrollbars. | |||||||||||
Change whether this view is one of the set of scrollable containers in
its window.
| |||||||||||
Changes the selection state of this view.
| |||||||||||
Set whether this view should have sound effects enabled for events such as
clicking and touching.
| |||||||||||
Sets the tag associated with this view.
| |||||||||||
Sets the TouchDelegate for this View.
| |||||||||||
Define whether the vertical edges should be faded when this view is scrolled vertically. | |||||||||||
Define whether the vertical scrollbar should be drawn or not. | |||||||||||
Set the enabled state of this view.
| |||||||||||
When a View's drawing cache is enabled, drawing is redirected to an
offscreen bitmap.
| |||||||||||
If this view doesn't do any drawing on its own, set this flag to
allow further optimizations.
| |||||||||||
Bring up the context menu for this view.
| |||||||||||
Start the specified animation now.
| |||||||||||
Cancels a scheduled action on a drawable.
| |||||||||||
Unschedule any events associated with the given Drawable.
| |||||||||||
Returns whether or not this View can cache its drawing or not.
| |||||||||||
Returns whether or not this View draws on its own.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Compute the horizontal extent of the horizontal scrollbar's thumb within the horizontal range. | |||||||||||
Compute the horizontal offset of the horizontal scrollbar's thumb within the horizontal range. | |||||||||||
Compute the horizontal range that the horizontal scrollbar represents. | |||||||||||
Compute the vertical extent of the horizontal scrollbar's thumb within the vertical range. | |||||||||||
Compute the vertical offset of the vertical scrollbar's thumb within the horizontal range. | |||||||||||
Compute the vertical range that the vertical scrollbar represents. | |||||||||||
Called by draw to draw the child views.
| |||||||||||
Called by restoreHierarchyState(SparseArray
| |||||||||||
Called by saveHierarchyState(SparseArray
| |||||||||||
Dispatch setPressed to all of this View's children.
| |||||||||||
Dispatch setSelected to all of this View's children.
| |||||||||||
This function is called whenever the state of the view changes in such
a way that it impacts the state of drawables being shown.
| |||||||||||
Is called before the object's memory is being reclaimed by the VM.
| |||||||||||
Apply the insets for system windows to this view, if the FITS_SYSTEM_WINDOWS flag
is set
| |||||||||||
Returns the strength, or intensity, of the bottom faded edge.
| |||||||||||
Amount by which to extend the bottom fading region.
| |||||||||||
Views should implement this if they have extra information to associate
with the context menu.
| |||||||||||
Returns the height of the horizontal scrollbar.
| |||||||||||
Returns the strength, or intensity, of the left faded edge.
| |||||||||||
Amount by which to extend the left fading region.
| |||||||||||
Returns the strength, or intensity, of the right faded edge.
| |||||||||||
Amount by which to extend the right fading region.
| |||||||||||
Returns the suggested minimum height that the view should use.
| |||||||||||
Returns the suggested minimum width that the view should use.
| |||||||||||
Returns the strength, or intensity, of the top faded edge.
| |||||||||||
Amount by which to extend the top fading region.
| |||||||||||
Initializes the fading edges from a given set of styled attributes. | |||||||||||
Initializes the scrollbars from a given set of styled attributes. | |||||||||||
If the View draws content inside its padding and enables fading edges,
it needs to support padding offsets.
| |||||||||||
Merge your own state values in additionalState into the base
state values baseState that were returned by
onCreateDrawableState(int).
| |||||||||||
Invoked by a parent ViewGroup to notify the end of the animation
currently associated with this view.
| |||||||||||
Invoked by a parent ViewGroup to notify the start of the animation
currently associated with this view.
| |||||||||||
This is called when the view is attached to a window.
| |||||||||||
Views should implement this if the view itself is going to add items to
the context menu.
| |||||||||||
Generate the new Drawable state for
this view.
| |||||||||||
This is called when the view is detached from a window.
| |||||||||||
Implement this to do your drawing.
| |||||||||||
Finalize inflating a view from XML.
| |||||||||||
Called by the view system when the focus state of this view changes.
| |||||||||||
Called from layout when this view should
assign a size and position to each of its children.
| |||||||||||
Measure the view and its content to determine the measured width and the measured height. | |||||||||||
Hook allowing a view to re-apply a representation of its internal state that had previously
been generated by 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 is called in response to an internal scroll in this view (i.e., the
view scrolled its own contents).
| |||||||||||
Invoked if there is a Transform that involves alpha.
| |||||||||||
This is called during layout when the size of this view has changed.
| |||||||||||
This mehod must be called by onMeasure(int, int) to store the measured width and measured height. | |||||||||||
If your view subclass is displaying its own Drawable objects, it should
override this function and return true for any Drawable it is
displaying.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
| |||||||||||
From interface android.graphics.drawable.Drawable.Callback
| |||||||||||
From interface android.view.KeyEvent.Callback
|
A drawable to use as the background. This can be either a reference to a full drawable resource (such as a PNG image, 9-patch, XML state list description, etc), or a solid color such as "#ff000000" (black).
May be a reference to another resource, in the form "@[+][package:]type:name
"
or to a theme attribute in the form "?[package:][type:]name
".
May be a color value, in the form of "#rgb
", "#argb
",
"#rrggbb
", or "#aarrggbb
".
This corresponds to the global attribute resource symbol background.
Defines whether this view reacts to click events.
Must be a boolean value, either "true
" or "false
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol clickable.
Defines the quality of translucent drawing caches. This property is used only when the drawing cache is enabled and translucent. The default value is auto.
Must be one of the following constant values.
Constant | Value | Description |
---|---|---|
auto | 0 | Lets the framework decide what quality level should be used for the drawing cache. |
low | 1 | Low quality. When set to low quality, the drawing cache uses a lower color depth, thus losing precision in rendering gradients, but uses less memory. |
high | 2 | High quality. When set to high quality, the drawing cache uses a higher color depth but uses more memory. |
This corresponds to the global attribute resource symbol drawingCacheQuality.
Defines which edges should be fadeded on scrolling.
Must be one or more (separated by '|') of the following constant values.
Constant | Value | Description |
---|---|---|
none | 0x00000000 | No edge is faded. |
horizontal | 0x00001000 | Fades horizontal edges only. |
vertical | 0x00002000 | Fades vertical edges only. |
This corresponds to the global attribute resource symbol fadingEdge.
Defines the length of the fading edges.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
".
Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
in (inches), mm (millimeters).
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol fadingEdgeLength.
Boolean internal attribute to adjust view layout based on system windows such as the status bar. If true, adjusts the padding of this view to leave space for the system windows. Will only take effect if this view is in a non-embedded activity.
Must be a boolean value, either "true
" or "false
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol fitsSystemWindows.
Boolean that controls whether a view can take focus. By default the user can not move focus to a view; by setting this attribute to true the view is allowed to take focus. This value does not impact the behavior of directly calling requestFocus(), which will always request focus regardless of this view. It only impacts where focus navigation will try to move focus.
Must be a boolean value, either "true
" or "false
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol focusable.
Boolean that controls whether a view can take focus while in touch mode. If this is true for a view, that view can gain focus when clicked on, and can keep focus if another view is clicked on that doesn't have this attribute set to true.
Must be a boolean value, either "true
" or "false
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol focusableInTouchMode.
Boolean that controls whether a view should have haptic feedback enabled for events such as long presses.
Must be a boolean value, either "true
" or "false
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol hapticFeedbackEnabled.
Supply an identifier name for this view, to later retrieve it
with View.findViewById() or
Activity.findViewById().
This must be a
resource reference; typically you set this using the
@+
syntax to create a new ID resources.
For example: android:id="@+id/my_id"
which
allows you to later retrieve the view
with findViewById(R.id.my_id)
.
Must be a reference to another resource, in the form "@[+][package:]type:name
"
or to a theme attribute in the form "?[package:][type:]name
".
This corresponds to the global attribute resource symbol id.
Controls whether the view's window should keep the screen on while visible.
Must be a boolean value, either "true
" or "false
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol keepScreenOn.
Defines whether this view reacts to long click events.
Must be a boolean value, either "true
" or "false
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol longClickable.
Defines the next view to give focus to when the next focus is FOCUS_DOWN If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a RuntimeException will result when the reference is accessed.
Must be a reference to another resource, in the form "@[+][package:]type:name
"
or to a theme attribute in the form "?[package:][type:]name
".
This corresponds to the global attribute resource symbol nextFocusDown.
Defines the next view to give focus to when the next focus is FOCUS_LEFT. If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a RuntimeException will result when the reference is accessed.
Must be a reference to another resource, in the form "@[+][package:]type:name
"
or to a theme attribute in the form "?[package:][type:]name
".
This corresponds to the global attribute resource symbol nextFocusLeft.
Defines the next view to give focus to when the next focus is FOCUS_RIGHT If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a RuntimeException will result when the reference is accessed.
Must be a reference to another resource, in the form "@[+][package:]type:name
"
or to a theme attribute in the form "?[package:][type:]name
".
This corresponds to the global attribute resource symbol nextFocusRight.
Defines the next view to give focus to when the next focus is FOCUS_UP If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a RuntimeException will result when the reference is accessed.
Must be a reference to another resource, in the form "@[+][package:]type:name
"
or to a theme attribute in the form "?[package:][type:]name
".
This corresponds to the global attribute resource symbol nextFocusUp.
Sets the padding, in pixels, of all four edges. Padding is defined as space between the edges of the view and the view's content. A views size will include it's padding. If a background is provided, the padding will initially be set to that (0 if the drawable does not have padding). Explicitly setting a padding value will override the corresponding padding found in the background.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
".
Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
in (inches), mm (millimeters).
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol padding.
Sets the padding, in pixels, of the bottom edge; see padding.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
".
Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
in (inches), mm (millimeters).
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol paddingBottom.
Sets the padding, in pixels, of the left edge; see padding.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
".
Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
in (inches), mm (millimeters).
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol paddingLeft.
Sets the padding, in pixels, of the right edge; see padding.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
".
Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
in (inches), mm (millimeters).
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol paddingRight.
Sets the padding, in pixels, of the top edge; see padding.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
".
Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
in (inches), mm (millimeters).
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol paddingTop.
If unset, no state will be saved for this view when it is being frozen. The default is true, allowing the view to be saved (however it also must have an ID assigned to it for its state to be saved). Setting this to false only disables the state for this view, not for its children which may still be saved.
Must be a boolean value, either "true
" or "false
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol saveEnabled.
The initial horizontal scroll offset, in pixels.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
".
Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
in (inches), mm (millimeters).
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol scrollX.
The initial vertical scroll offset, in pixels.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
".
Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
in (inches), mm (millimeters).
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol scrollY.
Defines whether the horizontal scrollbar track should always be drawn.
Must be a boolean value, either "true
" or "false
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol scrollbarAlwaysDrawHorizontalTrack.
Defines whether the vertical scrollbar track should always be drawn
Must be a boolean value, either "true
" or "false
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol scrollbarAlwaysDrawVerticalTrack.
Sets the width of vertical scrollbars and height of horizontal scrollbars.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
".
Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
in (inches), mm (millimeters).
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol scrollbarSize.
Defines the horizontal scrollbar thumb drawable.
Must be a reference to another resource, in the form "@[+][package:]type:name
"
or to a theme attribute in the form "?[package:][type:]name
".
This corresponds to the global attribute resource symbol scrollbarThumbHorizontal.
Defines the vertical scrollbar thumb drawable.
Must be a reference to another resource, in the form "@[+][package:]type:name
"
or to a theme attribute in the form "?[package:][type:]name
".
This corresponds to the global attribute resource symbol scrollbarThumbVertical.
Defines the horizontal scrollbar track drawable.
Must be a reference to another resource, in the form "@[+][package:]type:name
"
or to a theme attribute in the form "?[package:][type:]name
".
This corresponds to the global attribute resource symbol scrollbarTrackHorizontal.
Defines the vertical scrollbar track drawable.
Must be a reference to another resource, in the form "@[+][package:]type:name
"
or to a theme attribute in the form "?[package:][type:]name
".
This corresponds to the global attribute resource symbol scrollbarTrackVertical.
Defines which scrollbars should be displayed on scrolling or not.
Must be one or more (separated by '|') of the following constant values.
Constant | Value | Description |
---|---|---|
none | 0x00000000 | No scrollbar is displayed. |
horizontal | 0x00000100 | Displays horizontal scrollbar only. |
vertical | 0x00000200 | Displays vertical scrollbar only. |
This corresponds to the global attribute resource symbol scrollbars.
Boolean that controls whether a view should have sound effects enabled for events such as clicking and touching.
Must be a boolean value, either "true
" or "false
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol soundEffectsEnabled.
Controls the initial visibility of the view.
Must be one of the following constant values.
Constant | Value | Description |
---|---|---|
visible | 0 | Visible on screen; the default value. |
invisible | 1 | Not displayed, but taken into account during layout (space is left for it). |
gone | 2 | Completely hidden, as if the view had not been added. |
This corresponds to the global attribute resource symbol visibility.
Enables automatic quality mode for the drawing cache.
Enables high quality mode for the drawing cache.
Enables low quality mode for the drawing cache.
Indicates the view has no states set. States are used with Drawable to change the drawing of the view depending on its state.
Indicates the view is enabled, focused and selected.
Indicates the view is enabled, focused, selected and its window has the focus.
Indicates the view is enabled and has the focus.
Indicates the view is enabled, focused and its window has the focus.
Indicates the view is enabled and selected.
Indicates the view is enabled, selected and its window has the focus.
Indicates the view is enabled. States are used with Drawable to change the drawing of the view depending on its state.
Indicates the view is enabled and that its window has focus.
Indicates the view is focused and selected.
Indicates the view is focused, selected and its window has the focus.
Indicates the view is focused. States are used with Drawable to change the drawing of the view depending on its state.
Indicates the view has the focus and that its window has the focus.
Use with focusSearch(int). Move focus to the previous selectable item.
Use with focusSearch(int). Move focus down.
Use with focusSearch(int). Move focus to the next selectable item.
Use with focusSearch(int). Move focus to the left.
Use with focusSearch(int). Move focus to the right.
Use with focusSearch(int). Move focus up.
This view is invisible, and it doesn't take any space for layout purposes. Use with setVisibility(int).
View flag indicating whether this view should have haptic feedback enabled for events such as long presses.
This view is invisible, but it still takes up space for layout purposes. Use with setVisibility(int).
View flag indicating that the screen should remain on while the window containing this view is visible to the user. This effectively takes care of automatically setting the WindowManager's FLAG_KEEP_SCREEN_ON.
Used to mark a View that has no ID.
Indicates the view is pressed, enabled, focused and selected.
Indicates the view is pressed, enabled, focused, selected and its window has the focus.
Indicates the view is pressed, enabled and focused.
Indicates the view is pressed, enabled, focused and its window has the focus.
Indicates the view is pressed, enabled and selected.
Indicates the view is pressed, enabled, selected and its window has the focus.
Indicates the view is pressed and enabled.
Indicates the view is pressed, enabled and its window has the focus.
Indicates the view is pressed, focused and selected.
Indicates the view is pressed, focused, selected and its window has the focus.
Indicates the view is pressed and focused.
Indicates the view is pressed, focused and its window has the focus.
Indicates the view is pressed and selected.
Indicates the view is pressed, selected and its window has the focus.
Indicates the view is pressed and its window has the focus.
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.
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.
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.
The scrollbar style to display the scrollbars at the edge of the view, without increasing the padding. The scrollbars will be overlaid with translucency.
Indicates the view is selected. States are used with Drawable to change the drawing of the view depending on its state.
Indicates the view is selected and that its window has the focus.
View flag indicating whether this view should have sound effects enabled for events such as clicking and touching.
The logging tag used by this class with android.util.Log.
This view is visible. Use with setVisibility(int).
Indicates the view's window has focus. States are used with Drawable to change the drawing of the view depending on its state.
Simple constructor to use when creating a view from code.
context | The Context the view is running in, through which it can access the current theme, resources, etc. |
---|
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.
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. |
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.
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. |
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.
views | Focusable views found so far |
---|---|
direction | The direction of the focus |
Add any touchable views that are descendants of this view (possibly including this view if it is touchable itself) to views.
views | Touchable views found so far |
---|
Change the view's z order in the tree, so it's on top of other sibling views
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.
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.
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.
view | The View that is making the InputMethodManager call. |
---|
Cancels any animations for this view.
Called when this view wants to give up focus. This will cause onFocusChanged(boolean, int, Rect) to be called.
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.
Show the context menu for this view. It is not safe to hold on to the menu after returning from this method.
menu | The context menu to populate |
---|
Frees the resources used by the drawing cache. If you call buildDrawingCache() manually without calling setDrawingCacheEnabled(true), you should cleanup the cache with this method afterwards.
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.
event | The key event to be dispatched. |
---|
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.
event | The key event to be dispatched. |
---|
Dispatches a key shortcut event.
event | The key event to be dispatched. |
---|
Pass the touch screen motion event down to the target view, or this view if it is the target.
event | The motion event to be dispatched. |
---|
Pass a trackball motion event down to the focused view.
event | The motion event to be dispatched. |
---|
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.
focused | The currently focused view. |
---|---|
direction | The direction focus wants to move. One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT. |
Called when the window containing this view gains or loses window focus. ViewGroups should override to route to their children.
hasFocus | True if the window containing this view now has focus, false otherwise. |
---|
Dispatch a window visibility change down the view hierarchy. ViewGroups should override to route to their children.
visibility | The new visibility of the window. |
---|
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, do not override this method; instead, you should implement onDraw(Canvas).
canvas | The Canvas to which the View is rendered. |
---|
Find the view in the hierarchy rooted at this view that currently has focus.
Look for a child view with the given id. If this view has the given id, return this view.
id | The id to search for. |
---|
Look for a child view with the given tag. If this view has the given tag, return this view.
tag | The tag to search for, using "tag.equals(getTag())". |
---|
Find the nearest view in the specified direction that can take focus. This does not actually give focus to that view.
direction | One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT |
---|
Forces this view to be laid out during the next layout pass. This method does not call requestLayout() or forceLayout() on the parent.
Get the animation currently associated with this view.
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.
Gets the background drawable
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.
Bottom position of this view relative to its parent.
Returns the context the view is running in, through which it can access the current theme, resources, etc.
Utility to return a default size. Uses the supplied size if the MeasureSpec imposed no contraints. Will get larger if allowed by the MeasureSpec.
size | Default size for this view |
---|---|
measureSpec | Constraints imposed by the parent |
Return an array of resource IDs of the drawable states representing the current state of the view.
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.
Returns the quality of the drawing cache.
Return the visible drawing bounds of your view. Fills in the output rectangle with the values from getScrollX(), getScrollY(), getWidth(), and getHeight().
outRect | The (scrolled) drawing bounds of the view. |
---|
Return the time at which the drawing of the view hierarchy started.
Find and return all focusable views that are descendants of this view, possibly including this view if it is focusable itself.
direction | The direction of the focus |
---|
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 rectange is the getDrawingRect(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.
r | The rectangle to fill in, in this view's coordinates. |
---|
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, offset it by -globalOffset (e.g. r.offset(-globalOffset.x, -globalOffset.y)) If the view is completely clipped or translated out, return false.
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. |
Return the height of your view.
Hit rectangle in parent's coordinates
outRect | The hit rectangle of the view. |
---|
Returns the size of the horizontal faded edges used to indicate that more content in this view is visible.
Returns this view's identifier.
Returns whether the screen should remain on, corresponding to the current value of KEEP_SCREEN_ON.
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.
Left position of this view relative to its parent.
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.
location | an array of two integers in which to hold the coordinates |
---|
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.
location | an array of two integers in which to hold the coordinates |
---|
The height of this view as measured in the most recent call to measure(). This should be used during measurement and layout calculations only. Use getHeight() to see how tall a view is after layout.
The width of this view as measured in the most recent call to measure(). This should be used during measurement and layout calculations only. Use getWidth() to see how wide a view is after layout.
Returns the focus-change callback registered for this view.
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 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 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 top padding of this view.
Gets the parent of this view. Note that the parent is a ViewParent and not necessarily a View.
Returns the resources associated with this view.
Right position of this view relative to its parent.
Finds the topmost view in the current view hierarchy.
Returns the current scrollbar style.
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.
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.
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 this view's tag.
Top position of this view relative to its parent.
Gets the TouchDelegate for this View.
Find and return all touchable views that are descendants of this view, possibly including this view if it is touchable itself.
Returns the size of the vertical faded edges used to indicate that more content in this view is visible.
Returns the width of the vertical scrollbar.
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 isAlive().
Returns the visibility status for this view.
Return the width of the your view.
Retrieve a unique token identifying the window this view is attached to.
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.
outRect | Filled in with the visible display frame. If the view is not attached to a window, this is simply the raw display size. |
---|
Returns true if this view has focus iteself, or is the ancestor of the view that has focus.
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 this view is in a window that currently has window focus. Note that this is not the same as the view itself having focus.
Inflate a view from an XML resource. This convenience method wraps the LayoutInflater class, which provides a full range of options for view inflation.
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. |
Mark the 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(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().
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 the whole view. If the view is visible, onDraw(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().
Mark the the area defined by dirty as needing to be drawn. If the view is visible, onDraw(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.
dirty | the rectangle representing the bounds of the dirty region |
---|
Invalidates the specified Drawable.
drawable | the drawable to invalidate |
---|
Indicates whether this view reacts to click events or not.
Indicates whether the drawing cache is enabled for this view.
Indicates whether this duplicates its drawable state from its parent.
Returns the enabled status for this view. The interpretation of the enabled state varies by subclass.
Returns whether this View is able to take focus.
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 true if this view has focus
Indicate whether the horizontal edges are faded when the view is scrolled horizontally.
Indicate whether the horizontal scrollbar should be drawn or not. The scrollbar is not drawn by default.
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 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.
Indicates whether or not this view's layout will be requested during the next hierarchy layout pass.
Indicates whether this view reacts to long click events or not.
Indicates whether the view is currently in pressed state. Unless setPressed(boolean) is explicitly called, only clickable views can enter the pressed state.
Indicates whether this view will save its state (that is, whether its onSaveInstanceState() method will be called).
Indicates the selection state of this view.
Returns the visibility of this view and all of its ancestors
Indicate whether the vertical edges are faded when the view is scrolled horizontally.
Indicate whether the vertical scrollbar should be drawn or not. The scrollbar is not drawn by default.
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 with children should override onLayout. In that method, they should call layout on each of their their children.
l | Left position, relative to parent |
---|---|
t | Top position, relative to parent |
r | Right position, relative to parent |
b | Bottom position, relative to parent |
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 mesurement work of a view is performed in onMeasure(int, int), called by this method. Therefore, only onMeasure(int, int) can and must be overriden by subclasses.
widthMeasureSpec | Horizontal space requirements as imposed by the parent |
---|---|
heightMeasureSpec | Vertical space requirements as imposed by the parent |
Offset this view's horizontal location by the specified amount of pixels.
offset | the numer of pixels to offset the view by |
---|
Offset this view's vertical location by the specified number of pixels.
offset | the number of pixels to offset the view by |
---|
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.
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.
outAttrs | Fill in with attribute information about the connection. |
---|
Called after onStartTemporaryDetach() when the container is done changing the view.
Default implementation of KeyEvent.Callback.onKeyMultiple(): perform press of the view when KEYCODE_DPAD_CENTER or KEYCODE_ENTER is released, if the view is enabled and clickable.
keyCode | A key code that represents the button pressed, from KeyEvent. |
---|---|
event | The KeyEvent object that defines the button action. |
Default implementation of KeyEvent.Callback.onKeyMultiple(): always returns false (doesn't handle the event).
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. |
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.
keyCode | The value in event.getKeyCode(). |
---|---|
event | Description of the key event. |
Called when an unhandled key shortcut event occurs.
keyCode | The value in event.getKeyCode(). |
---|---|
event | Description of the key event. |
Default implementation of KeyEvent.Callback.onKeyMultiple(): perform clicking of the view when KEYCODE_DPAD_CENTER or KEYCODE_ENTER is released.
keyCode | A key code that represents the button pressed, from KeyEvent. |
---|---|
event | The KeyEvent object that defines the button action. |
This is called when a container is going to temporarily detach a child that currently has focus, with ViewGroup.detachViewFromParent. It will either be followed by onFinishTemporaryDetach() or onDetachedFromWindow() when the container is done. Generally this is currently only done ListView for a view with focus.
Implement this method to handle touch screen motion events.
event | The motion 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).
event | The motion event. |
---|
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.
hasWindowFocus | True if the window containing this view now has focus, false otherwise. |
---|
Call this view's OnClickListener, if it is defined.
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.
feedbackConstant | One of the constants defined in HapticFeedbackConstants |
---|
BZZZTT!!1!
Like performHapticFeedback(int), with additional options.
feedbackConstant | One of the constants defined in HapticFeedbackConstants |
---|---|
flags | Additional flags as per HapticFeedbackConstants. |
Call this view's OnLongClickListener, if it is defined. Invokes the context menu if the OnLongClickListener did not consume the event.
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.
soundConstant | One of the constants defined in SoundEffectConstants |
---|
Causes the Runnable to be added to the message queue. The runnable will be run on the user interface thread.
action | The Runnable that will be executed. |
---|
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.
action | The Runnable that will be executed. |
---|---|
delayMillis | The delay (in milliseconds) until the Runnable will be executed. |
Cause an invalidate to happen on a subsequent cycle through the event loop. Use this to invalidate the View from a non-UI thread.
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.
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. |
Cause an invalidate to happen on a subsequent cycle through the event loop. Waits for the specified amount of time.
delayMilliseconds | the duration in milliseconds to delay the invalidation by |
---|
Cause an invalidate of the specified area to happen on a subsequent cycle through the event loop. Waits for the specified amount of time.
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. |
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.
Removes the specified Runnable from the message queue.
action | The Runnable to remove from the message handling queue |
---|
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
.
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 getDescendantFocusability() equal to 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.
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. |
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.
direction | One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT |
---|
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.
Call this when something has changed which has invalidated the layout of this view. This will schedule a layout pass of the view tree.
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.
rectangle | The rectangle. |
---|---|
immediate | True to forbid animated scrolling, false otherwise |
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.
rectangle | The rectangle. |
---|
Utility to reconcile a desired size with constraints imposed by a MeasureSpec. Will take the desired size, unless a different size is imposed by the constraints.
size | How big the view wants to be |
---|---|
measureSpec | Constraints imposed by the parent |
Restore this view hierarchy's frozen state from the given container.
container | The SparseArray which holds previously frozen states. |
---|
Store this view hierarchy's frozen state into the given container.
container | The SparseArray in which to save the view's state. |
---|
Schedules an action on a drawable to occur at a specified time.
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 uptimeMillis() timebase. |
Move the scrolled position of your view. This will cause a call to onScrollChanged(int, int, int, int) and the view will be invalidated.
x | the amount of pixels to scroll by horizontally |
---|---|
y | the amount of pixels to scroll by vertically |
Set the scrolled position of your view. This will cause a call to onScrollChanged(int, int, int, int) and the view will be invalidated.
x | the x position to scroll to |
---|---|
y | the y position to scroll to |
Sets the next animation to play for this view. If you want the animation to play immediately, use startAnimation. 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 will be invalidated when the animation is supposed to start.
animation | The next animation, or null. |
---|
Sets the background color for this view.
color | the color of the 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).
d | The Drawable to use as the background, or null to remove the background |
---|
Set the background to a given resource. The resource should refer to a Drawable object.
resid | The identifier of the resource. |
---|
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.
clickable | true to make the view clickable, false otherwise |
---|
Setting a solid background color for the drawing cache's bitmaps will improve perfromance and memory usage. Note, though that this should only be used if this view will always be drawn on top of a solid color.
color | The background color to use for the drawing cache's bitmap |
---|
Enables or disables the drawing cache. When the drawing cache is enabled, the next call to getDrawingCache() or buildDrawingCache() will draw the view in a bitmap. 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 getDrawingCache() and draw it on screen if the returned bitmap is not null.
enabled | true to enable the drawing cache, false otherwise |
---|
Set the drawing cache quality of this view. This value is used only when the drawing cache is enabled
quality | One of DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_LOW, or DRAWING_CACHE_QUALITY_HIGH |
---|
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.
enabled | True to enable duplication of the parent's drawable state, false to disable it. |
---|
Set the enabled state of this view. The interpretation of the enabled state varies by subclass.
enabled | True if this view is enabled, false otherwise. |
---|
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.
length | The size in pixels of the faded edge used to indicate that more content in this view is visible. |
---|
Set whether this view can receive the focus. Setting this to false will also ensure that this view is not focusable in touch mode.
focusable | If true, this view can receive the focus. |
---|
Set whether this view can receive focus while in touch mode. Setting this to true will also ensure that this view is focusable.
focusableInTouchMode | If true, this view can receive the focus while in touch mode. |
---|
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.
hapticFeedbackEnabled | whether haptic feedback enabled for this view. |
---|
Define whether the horizontal edges should be faded when this view is scrolled horizontally.
horizontalFadingEdgeEnabled | true if the horizontal edges should be faded when the view is scrolled horizontally |
---|
Define whether the horizontal scrollbar should be drawn or not. The scrollbar is not drawn by default.
horizontalScrollBarEnabled | true if the horizontal scrollbar should be painted |
---|
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.
id | a number used to identify the view |
---|
Controls whether the screen should remain on, modifying the value of KEEP_SCREEN_ON.
keepScreenOn | Supply true to set KEEP_SCREEN_ON. |
---|
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.
params | the layout parameters for this view |
---|
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.
longClickable | true to make the view long clickable, false otherwise |
---|
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).
minHeight | The minimum height the view will try to be. |
---|
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).
minWidth | The minimum width the view will try to be. |
---|
Set the id of the view to use for the next focus
Set the id of the view to use for the next focus
Set the id of the view to use for the next focus
Set the id of the view to use for the next focus
Register a callback to be invoked when this view is clicked. If this view is not clickable, it becomes clickable.
l | The callback that will run |
---|
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.
l | The callback that will run |
---|
Register a callback to be invoked when focus of this view changed.
l | The callback that will run. |
---|
Register a callback to be invoked when a key is pressed in this view.
l | the key listener to attach to this view |
---|
Register a callback to be invoked when this view is clicked and held. If this view is not long clickable, it becomes long clickable.
l | The callback that will run |
---|
Register a callback to be invoked when a touch event is sent to this view.
l | the touch listener to attach to this view |
---|
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.
left | the left padding in pixels |
---|---|
top | the top padding in pixels |
right | the right padding in pixels |
bottom | the bottom padding in pixels |
Sets the pressed that for this view.
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. |
---|
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()) 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.
enabled | Set to false to disable state saving, or true (the default) to allow it. |
---|
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.
style | the style of the scrollbars. Should be one of SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_INSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY or SCROLLBARS_OUTSIDE_INSET. |
---|
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.
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.
selected | true if the view must be selected, false otherwise |
---|
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.
soundEffectsEnabled | whether sound effects are enabled for this view. |
---|
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.
tag | an Object to tag the view with |
---|
Sets the TouchDelegate for this View.
Define whether the vertical edges should be faded when this view is scrolled vertically.
verticalFadingEdgeEnabled | true if the vertical edges should be faded when the view is scrolled vertically |
---|
Define whether the vertical scrollbar should be drawn or not. The scrollbar is not drawn by default.
verticalScrollBarEnabled | true if the vertical scrollbar should be painted |
---|
Set the enabled state of this view.
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.
willNotCacheDrawing | true if this view does not cache its drawing, false otherwise |
---|
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(Canvas) you should clear this flag.
willNotDraw | whether or not this View draw on its own |
---|
Bring up the context menu for this view.
Start the specified animation now.
animation | the animation to start now |
---|
Cancels a scheduled action on a drawable.
who | the recipient of the action |
---|---|
what | the action to cancel |
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.
who | The Drawable to unschedule. |
---|
Returns whether or not this View can cache its drawing or not.
Returns whether or not this View draws on its own.
Compute the horizontal extent of the horizontal scrollbar's thumb within the horizontal range. This value is used to compute the length of the thumb within the scrollbar's track.
The range is expressed in arbitrary units that must be the same as the units used by computeHorizontalScrollRange() and computeHorizontalScrollOffset().
The default extent is the drawing width of this view.
Compute the horizontal offset of the horizontal scrollbar's thumb within the horizontal range. This value is used to compute the position of the thumb within the scrollbar's track.
The range is expressed in arbitrary units that must be the same as the units used by computeHorizontalScrollRange() and computeHorizontalScrollExtent().
The default offset is the scroll offset of this view.
Compute the horizontal range that the horizontal scrollbar represents.
The range is expressed in arbitrary units that must be the same as the units used by computeHorizontalScrollExtent() and computeHorizontalScrollOffset().
The default range is the drawing width of this view.
Compute the vertical extent of the horizontal scrollbar's thumb within the vertical range. This value is used to compute the length of the thumb within the scrollbar's track.
The range is expressed in arbitrary units that must be the same as the units used by computeHorizontalScrollRange() and computeVerticalScrollOffset().
The default extent is the drawing height of this view.
Compute the vertical offset of the vertical scrollbar's thumb within the horizontal range. This value is used to compute the position of the thumb within the scrollbar's track.
The range is expressed in arbitrary units that must be the same as the units used by computeVerticalScrollRange() and computeVerticalScrollExtent().
The default offset is the scroll offset of this view.
Compute the vertical range that the vertical scrollbar represents.
The range is expressed in arbitrary units that must be the same as the units used by computeVerticalScrollExtent() and computeVerticalScrollOffset().
The default range is the drawing height of this view.
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).
canvas | the canvas on which to draw the view |
---|
Called by restoreHierarchyState(SparseArray
container | The SparseArray which holds previously saved state. |
---|
Called by saveHierarchyState(SparseArray
container | The SparseArray in which to save the view's state. |
---|
Dispatch setPressed to all of this View's children.
pressed | The new pressed state |
---|
Dispatch setSelected to all of this View's children.
selected | The new selected state |
---|
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.
Is called before the object's memory is being reclaimed by the VM. This can only happen once the VM has detected, during a run of the garbage collector, that the object is no longer reachable by any thread of the running application.
The method can be used to free system resources or perform other cleanup
before the object is garbage collected. The default implementation of the
method is empty, which is also expected by the VM, but subclasses can
override finalize()
as required. Uncaught exceptions which are
thrown during the execution of this method cause it to terminate
immediately but are otherwise ignored.
Note that the VM does guarantee that finalize()
is called at most
once for any object, but it doesn't guarantee when (if at all) finalize()
will be called. For example, object B's finalize()
can delay the execution of object A's finalize()
method and
therefore it can delay the reclamation of A's memory. To be safe, use a
ReferenceQueue, because it provides more control
over the way the VM deals with references during garbage collection.
Throwable |
---|
Apply the insets for system windows to this view, if the FITS_SYSTEM_WINDOWS flag is set
insets | Insets for system windows |
---|
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.
Amount by which to extend the bottom fading region. Called only when isPaddingOffsetRequired() returns true.
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 onCreateContextMenu(ContextMenu, View, ContextMenuInfo) callback.
Returns the height of the horizontal scrollbar.
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.
Amount by which to extend the left fading region. Called only when isPaddingOffsetRequired() returns true.
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.
Amount by which to extend the right fading region. Called only when isPaddingOffsetRequired() returns true.
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 (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 width that the view should use. This returns the maximum of the view's minimum width) and the background's minimum width (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 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.
Amount by which to extend the top fading region. Called only when isPaddingOffsetRequired() returns true.
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.
a | the styled attributes set to initialize the fading edges from |
---|
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.
a | the styled attributes set to initialize the scrollbars from |
---|
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.
Merge your own state values in additionalState into the base state values baseState that were returned by onCreateDrawableState(int).
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. |
Invoked by a parent ViewGroup to notify the end of the animation currently associated with this view. If you override this method, always call super.onAnimationEnd();
Invoked by a parent ViewGroup to notify the start of the animation currently associated with this view. If you override this method, always call super.onAnimationStart();
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(Canvas), however it may be called any time before the first onDraw -- including before or after onMeasure(int, int).
Views should implement this if the view itself is going to add items to the context menu.
menu | the context menu to populate |
---|
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().
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. |
---|
This is called when the view is detached from a window. At this point it no longer has a surface for drawing.
Implement this to do your drawing.
canvas | the canvas on which the background will be drawn |
---|
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.
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.
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 View.FOCUS_UP, View.FOCUS_DOWN, View.FOCUS_LEFT or View.FOCUS_RIGHT. 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.
|
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 their children.
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 |
Measure the view and its content to determine the measured width and the measured height. This method is invoked by measure(int, int) and should be overriden by subclasses to provide accurate and efficient measurement of their contents.
CONTRACT: When overriding this method, you
must call setMeasuredDimension(int, int) to store the
measured width and height of this view. Failure to do so will trigger an
IllegalStateException
, thrown by
measure(int, int). Calling the superclass'
onMeasure(int, int) is a valid use.
The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec. Subclasses should override onMeasure(int, int) to provide better measurements of their content.
If this method is overridden, it is the subclass's responsibility to make sure the measured height and width are at least the view's minimum height and width (getSuggestedMinimumHeight() and getSuggestedMinimumWidth()).
widthMeasureSpec | horizontal space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec. |
---|---|
heightMeasureSpec | vertical space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec. |
Hook allowing a view to re-apply a representation of its internal state that had previously been generated by onSaveInstanceState(). This function will never be called with a null state.
state | The frozen state that had previously been returned by 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.
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.
l | Current horizontal scroll origin. |
---|---|
t | Current vertical scroll origin. |
oldl | Previous horizontal scroll origin. |
oldt | Previous vertical scroll origin. |
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.
alpha | The alpha (0..255) to apply to the view's drawing |
---|
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.
w | Current width of this view. |
---|---|
h | Current height of this view. |
oldw | Old width of this view. |
oldh | Old height of this view. |
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.
visibility | The new visibility of the window. |
---|
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.
measuredWidth | the measured width of this view |
---|---|
measuredHeight | the measured height of this view |
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.
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. |
---|