java.lang.Object | ||
android.view.View | Drawable.Callback KeyEvent.Callback |
The View
class represents the basic UI building block. A view
occupies a rectangular area on the screen and is responsible for drawing and
event handling. View
is the base class for widgets,
used to create interactive graphical user interfaces.
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.
The framework will not draw views that are not in the invalid region, and also will take care of drawing the views background for you.
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.
View.BaseSavedState | |
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. |
Attribute name | Related methods | |
---|---|---|
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: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:visibility | setVisibility(int) |
Controls the initial visibility of the view. |
Value | ||||
---|---|---|---|---|
int | DRAWING_CACHE_QUALITY_AUTO | Enables automatic quality mode for the drawing cache. |
0 | 0x00000000 |
int | DRAWING_CACHE_QUALITY_HIGH | Enables high quality mode for the drawing cache. |
1048576 | 0x00100000 |
int | DRAWING_CACHE_QUALITY_LOW | Enables low quality mode for the drawing cache. |
524288 | 0x00080000 |
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). | 1 | 0x00000001 |
int | FOCUS_DOWN | Use with focusSearch(int). | 130 | 0x00000082 |
int | FOCUS_FORWARD | Use with focusSearch(int). | 2 | 0x00000002 |
int | FOCUS_LEFT | Use with focusSearch(int). | 17 | 0x00000011 |
int | FOCUS_RIGHT | Use with focusSearch(int). | 66 | 0x00000042 |
int | FOCUS_UP | Use with focusSearch(int). | 33 | 0x00000021 |
int | GONE | This view is invisible, and it doesn't take any space for layout purposes. | 8 | 0x00000008 |
int | INVISIBLE | This view is invisible, but it still takes up space for layout purposes. | 4 | 0x00000004 |
int | KEEP_SCREEN_ON | View flag indicating that the screen should remain on while the window containing this view is visible to the user. | 67108864 | 0x04000000 |
int | NO_ID | Used to mark a View that has no ID. | -1 | 0xffffffff |
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. | 16777216 | 0x01000000 |
int | SCROLLBARS_INSIDE_OVERLAY | The scrollbar style to display the scrollbars inside the content area, without increasing the padding. | 0 | 0x00000000 |
int | SCROLLBARS_OUTSIDE_INSET | The scrollbar style to display the scrollbars at the edge of the view, increasing the padding of the view. | 50331648 | 0x03000000 |
int | SCROLLBARS_OUTSIDE_OVERLAY | The scrollbar style to display the scrollbars at the edge of the view, without increasing the padding. | 33554432 | 0x02000000 |
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. | ||
String | VIEW_LOG_TAG | The logging tag used by this class with android.util.Log. | "View" | |
int | VISIBLE | This view is visible. | 0 | 0x00000000 |
int[] | WINDOW_FOCUSED_STATE_SET | Indicates the view's window has focus. |
protected | int | mBottom | The distance in pixels from the top edge of this view's parent to the bottom edge of this view. | ||
protected | Context | mContext | The application environment this view lives in. | ||
protected | ViewGroup.LayoutParams | mLayoutParams | The layout parameters associated with this view and used by the parent ViewGroup to determine how this view should be laid out. | ||
protected | int | mLeft | The distance in pixels from the left edge of this view's parent to the left edge of this view. | ||
protected | final | int[] | mLocation | Used to store a pair of coordinates, for instance returned values returned by getLocationInWindow(int[]). | |
protected | View.OnClickListener | mOnClickListener | Listener used to dispatch click events. | ||
protected | View.OnCreateContextMenuListener | mOnCreateContextMenuListener | Listener used to build the context menu. | ||
protected | View.OnFocusChangeListener | mOnFocusChangeListener | Listener used to dispatch focus change events. | ||
protected | View.OnLongClickListener | mOnLongClickListener | Listener used to dispatch long click events. | ||
protected | int | mPaddingBottom | The bottom padding in pixels, that is the distance in pixels between the bottom edge of this view and the bottom edge of its content. | ||
protected | int | mPaddingLeft | The left padding in pixels, that is the distance in pixels between the left edge of this view and the left edge of its content. | ||
protected | int | mPaddingRight | The right padding in pixels, that is the distance in pixels between the right edge of this view and the right edge of its content. | ||
protected | int | mPaddingTop | The top padding in pixels, that is the distance in pixels between the top edge of this view and the top edge of its content. | ||
protected | ViewParent | mParent | The parent this view is attached to. | ||
protected | int | mRight | The distance in pixels from the left edge of this view's parent to the right edge of this view. | ||
protected | int | mScrollX | The offset, in pixels, by which the content of this view is scrolled horizontally. | ||
protected | int | mScrollY | The offset, in pixels, by which the content of this view is scrolled vertically. | ||
protected | Object | mTag | The view's tag. | ||
protected | int | mTop | The distance in pixels from the top edge of this view's parent to the top edge of this view. | ||
protected | int | mUserPaddingBottom | Cache the paddingBottom set by the user to append to the scrollbar's size. | ||
protected | int | mUserPaddingRight | Cache the paddingRight set by the user to append to the scrollbar's size. |
View(Context context) | ||||||
Simple constructor to use when creating a view from code. | ||||||
View(Context context, AttributeSet attrs) | ||||||
Constructor that is called when inflating a view from XML. | ||||||
View(Context context, AttributeSet attrs, int defStyle) | ||||||
Perform inflation from XML and apply a class-specific base style. |
void | addFocusables(ArrayList<View> views, int direction) | |||||
Add any focusable views that are descendants of this view (possibly including this view if it is focusable itself) to views. | ||||||
void | addTouchables(ArrayList<View> views) | |||||
Add any touchable views that are descendants of this view (possibly including this view if it is touchable itself) to views. | ||||||
void | bringToFront() | |||||
Change the view's z order in the tree, so it's on top of other sibling views | ||||||
void | buildDrawingCache() | |||||
Forces the drawing cache to be built if the drawing cache is invalid. |
||||||
void | cancelLongPress() | |||||
Cancels a pending long press. | ||||||
void | clearAnimation() | |||||
Cancels any animations for this view. | ||||||
void | clearFocus() | |||||
Called when this view wants to give up focus. | ||||||
void | computeScroll() | |||||
Called by a parent to request that a child update its values for mScrollX and mScrollY if necessary. | ||||||
void | createContextMenu(ContextMenu menu) | |||||
Show the context menu for this view. | ||||||
void | destroyDrawingCache() | |||||
Frees the resources used by the drawing cache. |
||||||
boolean | dispatchKeyEvent(KeyEvent event) | |||||
Dispatch a key event to the next view on the focus path. | ||||||
boolean | dispatchKeyShortcutEvent(KeyEvent event) | |||||
Dispatches a key shortcut event. | ||||||
boolean | dispatchTouchEvent(MotionEvent event) | |||||
Pass the touch screen motion event down to the target view, or this view if it is the target. | ||||||
boolean | dispatchTrackballEvent(MotionEvent event) | |||||
Pass a trackball motion event down to the focused view. | ||||||
boolean | dispatchUnhandledMove(View focused, int direction) | |||||
This method is the last chance for the focused view and its ancestors to respond to an arrow key. | ||||||
void | dispatchWindowFocusChanged(boolean hasFocus) | |||||
Called when the window containing this view gains or loses window focus. | ||||||
void | dispatchWindowVisibilityChanged(int visibility) | |||||
Dispatch a window visibility change down the view hierarchy. | ||||||
void | draw(Canvas canvas) | |||||
Manually render this view (and all of its children) to the given Canvas. | ||||||
View | findFocus() | |||||
Find the view in the hierarchy rooted at this view that currently has focus. | ||||||
final | View | findViewById(int id) | ||||
Look for a child view with the given id. | ||||||
final | View | findViewWithTag(Object tag) | ||||
Look for a child view with the given tag. | ||||||
View | focusSearch(int direction) | |||||
Find the nearest view in the specified direction that can take focus. | ||||||
void | forceLayout() | |||||
Forces this view to be laid out during the next layout pass. | ||||||
Animation | getAnimation() | |||||
Get the animation currently associated with this view. | ||||||
Drawable | getBackground() | |||||
Gets the background drawable | ||||||
int | getBaseline() | |||||
Return the offset of the widget's text baseline from the widget's top boundary. |
||||||
final | int | getBottom() | ||||
Bottom position of this view relative to its parent. | ||||||
final | Context | getContext() | ||||
Returns the context the view is running in, through which it can access the current theme, resources, etc. | ||||||
static | int | getDefaultSize(int size, int measureSpec) | ||||
Utility to return a default size. | ||||||
final | int[] | getDrawableState() | ||||
Return an array of resource IDs of the drawable states representing the current state of the view. | ||||||
Bitmap | getDrawingCache() | |||||
Returns the bitmap in which this view drawing is cached. |
||||||
int | getDrawingCacheBackgroundColor() | |||||
int | getDrawingCacheQuality() | |||||
Returns the quality of the drawing cache. | ||||||
void | getDrawingRect(Rect outRect) | |||||
Return the visible drawing bounds of your view. | ||||||
long | getDrawingTime() | |||||
Return the time at which the drawing of the view hierarchy started. |
||||||
ArrayList<View> | getFocusables(int direction) | |||||
Find and return all focusable views that are descendants of this view, possibly including this view if it is focusable itself. | ||||||
void | getFocusedRect(Rect r) | |||||
When a view has focus and the user navigates away from it, the next view is searched for starting from the rectangle filled in by this method. | ||||||
boolean | getGlobalVisibleRect(Rect r, Point globalOffset) | |||||
If some part of this view is not clipped by any of its parents, then return that area in r in global (root) coordinates. | ||||||
final | boolean | getGlobalVisibleRect(Rect r) | ||||
final | int | getHeight() | ||||
Return the height of your view. | ||||||
void | getHitRect(Rect outRect) | |||||
Hit rectangle in parent's coordinates | ||||||
int | getHorizontalFadingEdgeLength() | |||||
Returns the size of the horizontal faded edges used to indicate that more content in this view is visible. | ||||||
int | getId() | |||||
Returns this view's identifier. | ||||||
boolean | getKeepScreenOn() | |||||
Returns whether the screen should remain on, corresponding to the current value of KEEP_SCREEN_ON. | ||||||
ViewGroup.LayoutParams | getLayoutParams() | |||||
Get the LayoutParams associated with this view. | ||||||
final | int | getLeft() | ||||
Left position of this view relative to its parent. | ||||||
final | boolean | getLocalVisibleRect(Rect r) | ||||
void | getLocationInWindow(int[] location) | |||||
Computes the coordinates of this view in its window. |
||||||
void | getLocationOnScreen(int[] location) | |||||
Computes the coordinates of this view on the screen. |
||||||
final | int | getMeasuredHeight() | ||||
The height of this view as measured in the most recent call to measure(). | ||||||
final | int | getMeasuredWidth() | ||||
The width of this view as measured in the most recent call to measure(). | ||||||
int | getNextFocusDownId() | |||||
int | getNextFocusLeftId() | |||||
int | getNextFocusRightId() | |||||
int | getNextFocusUpId() | |||||
View.OnFocusChangeListener | getOnFocusChangeListener() | |||||
Returns the focus-change callback registered for this view. | ||||||
int | getPaddingBottom() | |||||
Returns the bottom padding of this view. | ||||||
int | getPaddingLeft() | |||||
Returns the left padding of this view. | ||||||
int | getPaddingRight() | |||||
Returns the right padding of this view. | ||||||
int | getPaddingTop() | |||||
Returns the top padding of this view. | ||||||
final | ViewParent | getParent() | ||||
Gets the parent of this view. | ||||||
Resources | getResources() | |||||
Returns the resources associated with this view. | ||||||
final | int | getRight() | ||||
Right position of this view relative to its parent. | ||||||
View | getRootView() | |||||
Finds the topmost view in the current view hierarchy. |
||||||
int | getScrollBarStyle() | |||||
Returns the current scrollbar style. |
||||||
final | int | getScrollX() | ||||
Return the scrolled left position of this view. | ||||||
final | int | getScrollY() | ||||
Return the scrolled top position of this view. | ||||||
int | getSolidColor() | |||||
Override this if your view is known to always be drawn on top of a solid color background, and needs to draw fading edges. | ||||||
Object | getTag() | |||||
Returns this view's tag. | ||||||
final | int | getTop() | ||||
Top position of this view relative to its parent. | ||||||
TouchDelegate | getTouchDelegate() | |||||
Gets the TouchDelegate for this View. | ||||||
ArrayList<View> | getTouchables() | |||||
Find and return all touchable views that are descendants of this view, possibly including this view if it is touchable itself. | ||||||
int | getVerticalFadingEdgeLength() | |||||
Returns the size of the vertical faded edges used to indicate that more content in this view is visible. | ||||||
int | getVerticalScrollbarWidth() | |||||
Returns the width of the vertical scrollbar. | ||||||
ViewTreeObserver | getViewTreeObserver() | |||||
Returns the ViewTreeObserver for this view's hierarchy. | ||||||
int | getVisibility() | |||||
Returns the visibility status for this view. | ||||||
final | int | getWidth() | ||||
Return the width of the your view. | ||||||
IBinder | getWindowToken() | |||||
Retrieve a unique token identifying the window this view is attached to. | ||||||
int | getWindowVisibility() | |||||
Returns the current visibility of the window this view is attached to (either GONE, INVISIBLE, or VISIBLE). | ||||||
boolean | hasFocus() | |||||
Returns true if this view has focus iteself, or is the ancestor of the view that has focus. | ||||||
boolean | hasFocusable() | |||||
Returns true if this view is focusable or if it contains a reachable View for which hasFocusable() returns true. | ||||||
boolean | hasWindowFocus() | |||||
Returns true if this view is in a window that currently has window focus. | ||||||
static | View | inflate(Context context, int resource, ViewGroup root) | ||||
Inflate a view from an XML resource. | ||||||
void | invalidate(int l, int t, int r, int b) | |||||
Mark the the area defined by the rect (l,t,r,b) as needing to be drawn. | ||||||
void | invalidate() | |||||
Invalidate the whole view. | ||||||
void | invalidate(Rect dirty) | |||||
Mark the the area defined by dirty as needing to be drawn. | ||||||
void | invalidateDrawable(Drawable drawable) | |||||
Invalidates the specified Drawable. | ||||||
boolean | isClickable() | |||||
Indicates whether this view reacts to click events or not. | ||||||
boolean | isDrawingCacheEnabled() | |||||
Indicates whether the drawing cache is enabled for this view. |
||||||
boolean | isDuplicateParentStateEnabled() | |||||
Indicates whether this duplicates its drawable state from its parent. |
||||||
boolean | isEnabled() | |||||
Returns the enabled status for this view. | ||||||
final | boolean | isFocusable() | ||||
Returns whether this View is able to take focus. | ||||||
final | boolean | isFocusableInTouchMode() | ||||
When a view is focusable, it may not want to take focus when in touch mode. | ||||||
boolean | isFocused() | |||||
Returns true if this view has focus | ||||||
boolean | isHorizontalFadingEdgeEnabled() | |||||
Indicate whether the horizontal edges are faded when the view is scrolled horizontally. |
||||||
boolean | isHorizontalScrollBarEnabled() | |||||
Indicate whether the horizontal scrollbar should be drawn or not. |
||||||
boolean | isInTouchMode() | |||||
Returns whether the device is currently in touch mode. | ||||||
boolean | isLayoutRequested() | |||||
Indicates whether or not this view's layout will be requested during the next hierarchy layout pass. |
||||||
boolean | isLongClickable() | |||||
Indicates whether this view reacts to long click events or not. | ||||||
boolean | isPressed() | |||||
Indicates whether the view is currently in pressed state. | ||||||
boolean | isSaveEnabled() | |||||
Indicates whether this view will save its state (that is, whether its onSaveInstanceState() method will be called). | ||||||
boolean | isSelected() | |||||
Indicates the selection state of this view. | ||||||
boolean | isShown() | |||||
Returns the visibility of this view and all of its ancestors | ||||||
boolean | isVerticalFadingEdgeEnabled() | |||||
Indicate whether the vertical edges are faded when the view is scrolled horizontally. |
||||||
boolean | isVerticalScrollBarEnabled() | |||||
Indicate whether the vertical scrollbar should be drawn or not. |
||||||
final | void | layout(int l, int t, int r, int b) | ||||
Assign a size and position to a view and all of its
descendants
This is the second phase of the layout mechanism. |
||||||
final | void | measure(int widthMeasureSpec, int heightMeasureSpec) | ||||
This is called to find out how big a view should be. |
||||||
boolean | onKeyDown(int keyCode, KeyEvent event) | |||||
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. | ||||||
boolean | onKeyMultiple(int keyCode, int repeatCount, KeyEvent event) | |||||
Default implementation of KeyEvent.Callback.onKeyMultiple(): always returns false (doesn't handle the event). | ||||||
boolean | onKeyShortcut(int keyCode, KeyEvent event) | |||||
Called when an unhandled key shortcut event occurs. | ||||||
boolean | onKeyUp(int keyCode, KeyEvent event) | |||||
Default implementation of KeyEvent.Callback.onKeyMultiple(): perform clicking of the view when KEYCODE_DPAD_CENTER or KEYCODE_ENTER is released. | ||||||
boolean | onTouchEvent(MotionEvent event) | |||||
Implement this method to handle touch screen motion events. | ||||||
boolean | onTrackballEvent(MotionEvent event) | |||||
Implement this method to handle trackball motion events. | ||||||
void | onWindowFocusChanged(boolean hasWindowFocus) | |||||
Called when the window containing this view gains or loses focus. | ||||||
boolean | performClick() | |||||
Call this view's OnClickListener, if it is defined. | ||||||
boolean | performLongClick() | |||||
Call this view's OnLongClickListener, if it is defined. | ||||||
boolean | post(Runnable action) | |||||
Causes the Runnable to be added to the message queue. | ||||||
boolean | postDelayed(Runnable action, long delayMillis) | |||||
Causes the Runnable to be added to the message queue, to be run after the specified amount of time elapses. | ||||||
void | postInvalidate() | |||||
Cause an invalidate to happen on a subsequent cycle through the event loop. | ||||||
void | postInvalidate(int left, int top, int right, int bottom) | |||||
Cause an invalidate of the specified area to happen on a subsequent cycle through the event loop. | ||||||
void | postInvalidateDelayed(long delayMilliseconds) | |||||
Cause an invalidate to happen on a subsequent cycle through the event loop. | ||||||
void | postInvalidateDelayed(long delayMilliseconds, int left, int top, int right, int bottom) | |||||
Cause an invalidate of the specified area to happen on a subsequent cycle through the event loop. | ||||||
void | refreshDrawableState() | |||||
Call this to force a view to update its drawable state. | ||||||
boolean | removeCallbacks(Runnable action) | |||||
Removes the specified Runnable from the message queue. | ||||||
final | boolean | requestFocus() | ||||
Call this to try to give focus to a specific view or to one of its descendants. | ||||||
boolean | requestFocus(int direction, Rect previouslyFocusedRect) | |||||
Call this to try to give focus to a specific view or to one of its descendants and give it hints about the direction and a specific rectangle that the focus is coming from. | ||||||
final | boolean | requestFocus(int direction) | ||||
Call this to try to give focus to a specific view or to one of its descendants and give it a hint about what direction focus is heading. | ||||||
final | boolean | requestFocusFromTouch() | ||||
Call this to try to give focus to a specific view or to one of its descendants. | ||||||
void | requestLayout() | |||||
Call this when something has changed which has invalidated the layout of this view. | ||||||
boolean | requestRectangleOnScreen(Rect rectangle, boolean immediate) | |||||
Request that a rectangle of this view be visible on the screen, scrolling if necessary just enough. | ||||||
boolean | requestRectangleOnScreen(Rect rectangle) | |||||
Request that a rectangle of this view be visible on the screen, scrolling if necessary just enough. | ||||||
static | int | resolveSize(int size, int measureSpec) | ||||
Utility to reconcile a desired size with constraints imposed by a MeasureSpec. | ||||||
void | restoreHierarchyState(SparseArray<Parcelable> container) | |||||
Restore this view hierarchy's frozen state from the given container. | ||||||
void | saveHierarchyState(SparseArray<Parcelable> container) | |||||
Store this view hierarchy's frozen state into the given container. | ||||||
void | scheduleDrawable(Drawable who, Runnable what, long when) | |||||
Schedules an action on a drawable to occur at a specified time. | ||||||
void | scrollBy(int x, int y) | |||||
Move the scrolled position of your view. | ||||||
void | scrollTo(int x, int y) | |||||
Set the scrolled position of your view. | ||||||
void | setAnimation(Animation animation) | |||||
Sets the next animation to play for this view. | ||||||
void | setBackgroundColor(int color) | |||||
Sets the background color for this view. | ||||||
void | setBackgroundDrawable(Drawable d) | |||||
Set the background to a given Drawable, or remove the background. | ||||||
void | setBackgroundResource(int resid) | |||||
Set the background to a given resource. | ||||||
void | setClickable(boolean clickable) | |||||
Enables or disables click events for this view. | ||||||
void | setDrawingCacheBackgroundColor(int color) | |||||
Setting a solid background color for the drawing cache's bitmaps will improve perfromance and memory usage. | ||||||
void | setDrawingCacheEnabled(boolean enabled) | |||||
Enables or disables the drawing cache. |
||||||
void | setDrawingCacheQuality(int quality) | |||||
Set the drawing cache quality of this view. | ||||||
void | setDuplicateParentStateEnabled(boolean enabled) | |||||
Enables or disables the duplication of the parent's state into this view. |
||||||
void | setEnabled(boolean enabled) | |||||
Set the enabled state of this view. | ||||||
void | setFadingEdgeLength(int length) | |||||
Set the size of the faded edge used to indicate that more content in this view is available. | ||||||
void | setFocusable(boolean focusable) | |||||
Set whether this view can receive the focus. | ||||||
void | setFocusableInTouchMode(boolean focusableInTouchMode) | |||||
Set whether this view can receive focus while in touch mode. | ||||||
void | setHorizontalFadingEdgeEnabled(boolean horizontalFadingEdgeEnabled) | |||||
Define whether the horizontal edges should be faded when this view is scrolled horizontally. |
||||||
void | setHorizontalScrollBarEnabled(boolean horizontalScrollBarEnabled) | |||||
Define whether the horizontal scrollbar should be drawn or not. |
||||||
void | setId(int id) | |||||
Sets the identifier for this view. | ||||||
void | setKeepScreenOn(boolean keepScreenOn) | |||||
Controls whether the screen should remain on, modifying the value of KEEP_SCREEN_ON. | ||||||
void | setLayoutParams(ViewGroup.LayoutParams params) | |||||
Set the layout parameters associated with this view. | ||||||
void | setLongClickable(boolean longClickable) | |||||
Enables or disables long click events for this view. | ||||||
void | setMinimumHeight(int minHeight) | |||||
Sets the minimum height of the view. | ||||||
void | setMinimumWidth(int minWidth) | |||||
Sets the minimum width of the view. | ||||||
void | setNextFocusDownId(int nextFocusDownId) | |||||
Set the id of the view to use for the next focus | ||||||
void | setNextFocusLeftId(int nextFocusLeftId) | |||||
Set the id of the view to use for the next focus | ||||||
void | setNextFocusRightId(int nextFocusRightId) | |||||
Set the id of the view to use for the next focus | ||||||
void | setNextFocusUpId(int nextFocusUpId) | |||||
Set the id of the view to use for the next focus | ||||||
void | setOnClickListener(View.OnClickListener l) | |||||
Register a callback to be invoked when this view is clicked. | ||||||
void | setOnCreateContextMenuListener(View.OnCreateContextMenuListener l) | |||||
Register a callback to be invoked when the context menu for this view is being built. | ||||||
void | setOnFocusChangeListener(View.OnFocusChangeListener l) | |||||
Register a callback to be invoked when focus of this view changed. | ||||||
void | setOnKeyListener(View.OnKeyListener l) | |||||
Register a callback to be invoked when a key is pressed in this view. | ||||||
void | setOnLongClickListener(View.OnLongClickListener l) | |||||
Register a callback to be invoked when this view is clicked and held. | ||||||
void | setOnTouchListener(View.OnTouchListener l) | |||||
Register a callback to be invoked when a touch event is sent to this view. | ||||||
void | setPadding(int left, int top, int right, int bottom) | |||||
Sets the padding. | ||||||
void | setPressed(boolean pressed) | |||||
Sets the pressed that for this view. | ||||||
void | setSaveEnabled(boolean enabled) | |||||
Controls whether the saving of this view's state is enabled (that is, whether its onSaveInstanceState() method will be called). | ||||||
void | setScrollBarStyle(int style) | |||||
Specify the style of the scrollbars. |
||||||
void | setSelected(boolean selected) | |||||
Changes the selection state of this view. | ||||||
void | setTag(Object tag) | |||||
Sets the tag associated with this view. | ||||||
void | setTouchDelegate(TouchDelegate delegate) | |||||
Sets the TouchDelegate for this View. | ||||||
void | setVerticalFadingEdgeEnabled(boolean verticalFadingEdgeEnabled) | |||||
Define whether the vertical edges should be faded when this view is scrolled vertically. |
||||||
void | setVerticalScrollBarEnabled(boolean verticalScrollBarEnabled) | |||||
Define whether the vertical scrollbar should be drawn or not. |
||||||
void | setVisibility(int visibility) | |||||
Set the enabled state of this view. | ||||||
void | setWillNotCacheDrawing(boolean willNotCacheDrawing) | |||||
When a View's drawing cache is enabled, drawing is redirected to an offscreen bitmap. | ||||||
void | setWillNotDraw(boolean willNotDraw) | |||||
If this view doesn't do any drawing on its own, set this flag to allow further optimizations. | ||||||
boolean | showContextMenu() | |||||
Bring up the context menu for this view. | ||||||
void | startAnimation(Animation animation) | |||||
Start the specified animation now. | ||||||
void | unscheduleDrawable(Drawable who, Runnable what) | |||||
Cancels a scheduled action on a drawable. | ||||||
void | unscheduleDrawable(Drawable who) | |||||
Unschedule any events associated with the given Drawable. | ||||||
boolean | willNotCacheDrawing() | |||||
Returns whether or not this View can cache its drawing or not. | ||||||
boolean | willNotDraw() | |||||
Returns whether or not this View draws on its own. |
int | computeHorizontalScrollExtent() | |||||
Compute the horizontal extent of the horizontal scrollbar's thumb within the horizontal range. |
||||||
int | computeHorizontalScrollOffset() | |||||
Compute the horizontal offset of the horizontal scrollbar's thumb within the horizontal range. |
||||||
int | computeHorizontalScrollRange() | |||||
Compute the horizontal range that the horizontal scrollbar represents. |
||||||
int | computeVerticalScrollExtent() | |||||
Compute the vertical extent of the horizontal scrollbar's thumb within the vertical range. |
||||||
int | computeVerticalScrollOffset() | |||||
Compute the vertical offset of the vertical scrollbar's thumb within the horizontal range. |
||||||
int | computeVerticalScrollRange() | |||||
Compute the vertical range that the vertical scrollbar represents. |
||||||
void | dispatchDraw(Canvas canvas) | |||||
Called by draw to draw the child views. | ||||||
void | dispatchRestoreInstanceState(SparseArray<Parcelable> container) | |||||
Called by restoreHierarchyState(SparseArray |
||||||
void | dispatchSaveInstanceState(SparseArray<Parcelable> container) | |||||
Called by saveHierarchyState(SparseArray |
||||||
void | dispatchSetPressed(boolean pressed) | |||||
Dispatch setPressed to all of this View's children. | ||||||
void | dispatchSetSelected(boolean selected) | |||||
Dispatch setSelected to all of this View's children. | ||||||
void | drawableStateChanged() | |||||
This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown. | ||||||
void | finalize() | |||||
Called by the virtual machine when there are no longer any (non-weak) references to the receiver. | ||||||
boolean | fitSystemWindows(Rect insets) | |||||
Apply the insets for system windows to this view, if the FITS_SYSTEM_WINDOWS flag is set | ||||||
float | getBottomFadingEdgeStrength() | |||||
Returns the strength, or intensity, of the bottom faded edge. | ||||||
ContextMenu.ContextMenuInfo | getContextMenuInfo() | |||||
Views should implement this if they have extra information to associate with the context menu. | ||||||
Handler | getHandler() | |||||
int | getHorizontalScrollbarHeight() | |||||
Returns the height of the horizontal scrollbar. | ||||||
float | getLeftFadingEdgeStrength() | |||||
Returns the strength, or intensity, of the left faded edge. | ||||||
float | getRightFadingEdgeStrength() | |||||
Returns the strength, or intensity, of the right faded edge. | ||||||
int | getSuggestedMinimumHeight() | |||||
Returns the suggested minimum height that the view should use. | ||||||
int | getSuggestedMinimumWidth() | |||||
Returns the suggested minimum width that the view should use. | ||||||
float | getTopFadingEdgeStrength() | |||||
Returns the strength, or intensity, of the top faded edge. | ||||||
int | getWindowAttachCount() | |||||
void | initializeFadingEdge(TypedArray a) | |||||
Initializes the fading edges from a given set of styled attributes. |
||||||
void | initializeScrollbars(TypedArray a) | |||||
Initializes the scrollbars from a given set of styled attributes. |
||||||
static | int[] | mergeDrawableStates(int[] baseState, int[] additionalState) | ||||
Merge your own state values in additionalState into the base state values baseState that were returned by onCreateDrawableState(int). | ||||||
void | onAnimationEnd() | |||||
Invoked by a parent ViewGroup to notify the end of the animation currently associated with this view. | ||||||
void | onAnimationStart() | |||||
Invoked by a parent ViewGroup to notify the start of the animation currently associated with this view. | ||||||
void | onAttachedToWindow() | |||||
This is called when the view is attached to a window. | ||||||
void | onCreateContextMenu(ContextMenu menu) | |||||
Views should implement this if the view itself is going to add items to the context menu. | ||||||
int[] | onCreateDrawableState(int extraSpace) | |||||
Generate the new Drawable state for this view. | ||||||
void | onDetachedFromWindow() | |||||
This is called when the view is detached from a window. | ||||||
void | onDraw(Canvas canvas) | |||||
Implement this to do your drawing. | ||||||
void | onFinishInflate() | |||||
Finalize inflating a view from XML. | ||||||
void | onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) | |||||
Called by the view system when the focus state of this view changes. | ||||||
void | onLayout(boolean changed, int left, int top, int right, int bottom) | |||||
Called from layout when this view should assign a size and position to each of its children. | ||||||
void | onMeasure(int widthMeasureSpec, int heightMeasureSpec) | |||||
Measure the view and its content to determine the measured width and the measured height. |
||||||
void | onRestoreInstanceState(Parcelable state) | |||||
Hook allowing a view to re-apply a representation of its internal state that had previously been generated by onSaveInstanceState(). | ||||||
Parcelable | onSaveInstanceState() | |||||
Hook allowing a view to generate a representation of its internal state that can later be used to create a new instance with that same state. | ||||||
void | onScrollChanged(int l, int t, int oldl, int oldt) | |||||
This is called in response to an internal scroll in this view (i.e., the view scrolled its own contents). | ||||||
boolean | onSetAlpha(int alpha) | |||||
Invoked if there is a Transform that involves alpha. | ||||||
void | onSizeChanged(int w, int h, int oldw, int oldh) | |||||
This is called during layout when the size of this view has changed. | ||||||
void | onWindowVisibilityChanged(int visibility) | |||||
Called when the window containing has change its visibility (between GONE, INVISIBLE, and VISIBLE). | ||||||
final | void | setMeasuredDimension(int measuredWidth, int measuredHeight) | ||||
This mehod must be called by onMeasure(int, int) to store the measured width and measured height. |
||||||
boolean | verifyDrawable(Drawable who) | |||||
If your view subclass is displaying its own Drawable objects, it should override this function and return true for any Drawable it is displaying. |
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.
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.
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.
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.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
".
Available units are: px (pixels), db (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.
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.
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.
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.
@+
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.
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 is a private symbol.
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.
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.
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.
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.
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.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
".
Available units are: px (pixels), db (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.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
".
Available units are: px (pixels), db (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.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
".
Available units are: px (pixels), db (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.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
".
Available units are: px (pixels), db (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.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
".
Available units are: px (pixels), db (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.
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.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
".
Available units are: px (pixels), db (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.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
".
Available units are: px (pixels), db (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.
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.
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.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
".
Available units are: px (pixels), db (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.
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.
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.
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.
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.
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.
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.
context | The Context the view is running in, through which it can access the current theme, resources, etc. |
---|
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. |
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. |
views | Focusable views found so far |
---|---|
direction | The direction of the focus |
views | Touchable views found so far |
---|
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.
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.
event | The key event to be dispatched. |
---|
event | The key event to be dispatched. |
---|
event | The motion event to be dispatched. |
---|
event | The motion event to be dispatched. |
---|
focused | The currently focused view. |
---|---|
direction | The direction focus wants to move. One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT. |
hasFocus | True if the window containing this view now has focus, false otherwise. |
---|
visibility | The new visibility of the window. |
---|
canvas | The Canvas to which the View is rendered. |
---|
id | The id to search for. |
---|
tag | The tag to search for, using "tag.equals(getTag())". |
---|
direction | One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT |
---|
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.
size | Default size for this view |
---|---|
measureSpec | Constraints imposed by the parent |
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.
outRect | The (scrolled) drawing bounds of the view. |
---|
Return the time at which the drawing of the view hierarchy started.
direction | The direction of the focus |
---|
r | The rectangle to fill in, in this view's coordinates. |
---|
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. |
outRect | The hit rectangle of the view. |
---|
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 |
---|
Finds the topmost view in the current view hierarchy.
Returns the current scrollbar style.
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. |
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 |
dirty | the rectangle representing the bounds of the dirty region |
---|
drawable | the drawable to invalidate |
---|
Indicates whether the drawing cache is enabled for this view.
Indicates whether this duplicates its drawable state from its parent.
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 or not this view's layout will be requested during the next hierarchy layout pass.
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.
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 |
keyCode | A key code that represents the button pressed, from KeyEvent. |
---|---|
event | The KeyEvent object that defines the button action. |
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. |
keyCode | The value in event.getKeyCode(). |
---|---|
event | Description of the key event. |
keyCode | A key code that represents the button pressed, from KeyEvent. |
---|---|
event | The KeyEvent object that defines the button action. |
event | The motion event. |
---|
event | The motion event. |
---|
hasWindowFocus | True if the window containing this view now has focus, false otherwise. |
---|
action | The Runnable that will be executed. |
---|
action | The Runnable that will be executed. |
---|---|
delayMillis | The delay (in milliseconds) until the Runnable will be executed. |
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. |
delayMilliseconds | the duration in milliseconds to delay the invalidation by |
---|
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. |
action | The Runnable to remove from the message handling queue |
---|
null
.
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. |
null
set for the previously focused rectangle.
direction | One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT |
---|
immediate
is set to true, scrolling will not be
animated.
rectangle | The rectangle. |
---|---|
immediate | True to forbid animated scrolling, false otherwise |
rectangle | The rectangle. |
---|
size | How big the view wants to be |
---|---|
measureSpec | Constraints imposed by the parent |
container | The SparseArray which holds previously frozen states. |
---|
container | The SparseArray in which to save the view's state. |
---|
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. |
x | the amount of pixels to scroll by horizontally |
---|---|
y | the amount of pixels to scroll by vertically |
x | the x position to scroll to |
---|---|
y | the y position to scroll to |
animation | The next animation, or null. |
---|
color | the color of the background |
---|
d | The Drawable to use as the background, or null to remove the background |
---|
resid | The identifier of the resource. |
---|
clickable | true to make the view clickable, false otherwise |
---|
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 |
---|
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. |
---|
enabled | True if this view is enabled, false otherwise. |
---|
length | The size in pixels of the faded edge used to indicate that more content in this view is visible. |
---|
focusable | If true, this view can receive the focus. |
---|
focusableInTouchMode | If true, this view can receive the focus while in touch mode. |
---|
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 |
---|
id | a number used to identify the view |
---|
keepScreenOn | Supply true to set KEEP_SCREEN_ON. |
---|
params | the layout parameters for this view |
---|
longClickable | true to make the view long clickable, false otherwise |
---|
minHeight | The minimum height the view will try to be. |
---|
minWidth | The minimum width the view will try to be. |
---|
l | The callback that will run |
---|
l | The callback that will run |
---|
l | The callback that will run. |
---|
l | the key listener to attach to this view |
---|
l | The callback that will run |
---|
l | the touch listener to attach to this view |
---|
left | the left padding in pixels |
---|---|
top | the top padding in pixels |
right | the right padding in pixels |
bottom | the bottom padding in pixels |
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. |
---|
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. |
---|
selected | true if the view must be selected, false otherwise |
---|
tag | an Object to tag the view with |
---|
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 |
---|
willNotCacheDrawing | true if this view does not cache its drawing, false otherwise |
---|
willNotDraw | whether or not this View draw on its own |
---|
animation | the animation to start now |
---|
who | the recipient of the action |
---|---|
what | the action to cancel |
who | The Drawable to unschedule. |
---|
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.
canvas | the canvas on which to draw the view |
---|
container | The SparseArray which holds previously saved state. |
---|
container | The SparseArray in which to save the view's state. |
---|
pressed | The new pressed state |
---|
selected | The new selected state |
---|
Be sure to call through to the superclass when overriding this function.
Note: The virtual machine assumes that the implementation in class Object is empty.
Throwable |
---|
insets | Insets for system windows |
---|
When being used in onMeasure(int, int), the caller should still ensure the returned height is within the requirements of the parent.
When being used in onMeasure(int, int), the caller should still ensure the returned width is within the requirements of the parent.
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 |
---|
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. |
menu | the context menu to populate |
---|
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. |
---|
canvas | the canvas on which the background will be drawn |
---|
Even if the subclass overrides onFinishInflate, they should always be sure to call the super method, so that we get called.
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.
|
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. |
state | The frozen state that had previously been returned by onSaveInstanceState(). |
---|
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.
l | Current horizontal scroll origin. |
---|---|
t | Current vertical scroll origin. |
oldl | Previous horizontal scroll origin. |
oldt | Previous vertical scroll origin. |
alpha | The alpha (0..255) to apply to the view's drawing |
---|
w | Current width of this view. |
---|---|
h | Current height of this view. |
oldw | Old width of this view. |
oldh | Old height of this view. |
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 |
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. |
---|
Copyright 2007 Google Inc. | Build 0.9_r1-98467 - 14 Aug 2008 18:48 |