View
declare class View extends Drawable.Callback {}
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
Attribute
id
<FrameLayout>
<View id="@+id/unique" />
</FrameLayout>
Description
Supply an identifier name for this view, to later retrieve it.
onClick
<FrameLayout>
<View onClick="function"/>
</FrameLayout>
Description
Bind window method name
clickable
<FrameLayout>
<View clickable="true"/>
</FrameLayout>
Description
Defines whether this view reacts to click events.
scrollbars
<FrameLayout>
<View scrollbars="none"/>
</FrameLayout>
Description
Defines which scrollbars should be displayed on scrolling or not.vertical
horizontal
none
translationX
<FrameLayout>
<View translationX="10px"/>
</FrameLayout>
Description
translation in x of the view.
translationY
<FrameLayout>
<View translationY="10px"/>
</FrameLayout>
Description
translation in y of the view.
rotation
<FrameLayout>
<View rotation="10px"/>
</FrameLayout>
Description
rotation of the view, in degrees.
alpha
<FrameLayout>
<View alpha="0.5"/>
</FrameLayout>
Description
alpha property of the view, as a value between 0 (completely transparent) and 1 (completely opaque).
scaleX
<FrameLayout>
<View scaleX="10"/>
</FrameLayout>
Description
scale of the view in the x direction
scaleY
<FrameLayout>
<View scaleY="10"/>
</FrameLayout>
Description
scale of the view in the y direction.
background
<FrameLayout>
<View background="@drawable/background"/>
<View background="#ffffff"/>
<View background="rgb(0,0,0)"/>
<View background="rgba(0,0,0,0.5)"/>
</FrameLayout>
Description
A drawable to use as the background.
scrollX
<FrameLayout>
<View scrollX="10px"/>
</FrameLayout>
Description
The initial horizontal scroll offset, in pixels.
scrollY
<FrameLayout>
<View scrollY="10px"/>
</FrameLayout>
Description
The initial vertical scroll offset, in pixels.
visibility
<FrameLayout>
<View visibility="gone"/>
</FrameLayout>
Description
Controls the initial visibility of the view.visible
invisible
gone
padding
<FrameLayout>
<View padding="10px"/>
</FrameLayout>
Description
Sets the padding, in pixels, of all four edges.
radius
<FrameLayout>
<View radius="10px"/>
</FrameLayout>
Description
view radius
paddingLeft
<FrameLayout>
<View paddingLeft="10px"/>
</FrameLayout>
Description
Sets the padding, in pixels, of the left edge
paddingRight
<FrameLayout>
<View paddingRight="10px"/>
</FrameLayout>
Description
Sets the padding, in pixels, of the right edge
paddingTop
<FrameLayout>
<View paddingTop="10px"/>
</FrameLayout>
Description
Sets the padding, in pixels, of the top edge
paddingBottom
<FrameLayout>
<View paddingBottom="10px"/>
</FrameLayout>
Description
Sets the padding, in pixels, of the bottom edge
transformPivotX
<FrameLayout>
<View transformPivotY="10px"/>
</FrameLayout>
Description
x location of the pivot point around which the view will rotate and scale.
transformPivotY
<FrameLayout>
<View transformPivotY="10px"/>
</FrameLayout>
Description
y location of the pivot point around which the view will rotate and scale.
Static Property
INVISIBLE
Type
declare class View {
static INVISIBLE: number;
}
Description
This view is invisible, but it still takes up space for layout purposes
VISIBLE
Type
declare class View {
static VISIBLE: number;
}
Description
This view is visible
GONE
Type
declare class View {
static GONE: number;
}
Description
This view is invisible, and it doesn't take any space for layout purposes
Static Method
resolveSize
Signature
declare class View {
static resolveSize(size: number, measureSpec: number): number;
}
Description
Utility to reconcile a desired size and state, with constraints imposed by a MeasureSpec.
getMode
Signature
declare class View {
static getMode(measureSpec: number): number;
}
Description
Extracts the mode from the supplied measure specification.
getDefaultSize
Signature
declare class View {
static getDefaultSize(size: number, measureSpec: number): number;
}
Description
Utility to return a default size.
Instance Method
constructor
Signature
declare class View {
constructor(context: Context, attr: AttributeSet);
}
Description
Create a new view instance.
invalidate
Signature
declare class View {
invalidate():void;
}
Description
Invalidate the whole view. If the view is visible, will be called at some point in the future.onDraw(Canvas)
.
invalidate
Signature
declare class View {
invalidate(l: number, t: number, r: number, b: number):void
}
Description
Mark the area defined by the rect (l,t,r,b) as needing to be drawn. The coordinates of the dirty rect are relative to the view. If the view is visible, will be called at some point in the future.onDraw(Canvas)
.
requestLayout
Signature
declare class View {
invalidate();
}
Description
Call this when something has changed which has invalidated the layout of this view. This will schedule a layout pass of the view tree.
post
Signature
declare class View {
post(action:Runnable): boolean;
}
Description
Causes the Runnable to be added to the message queue.
hasFocus
Signature
declare class View {
hasFocus(): boolean;
}
Description
Returns true if this view has focus itself, or is the ancestor of the view that has focus.
requestFocus
Signature
declare class View {
requestFocus(): boolean;
}
Description
Calling this function can attempt to focus on a specific view or its sub views.
clearFocus
Signature
declare class View {
clearFocus(): void;
}
Description
Called when this view wants to give up focus. If focus is cleared is called.onFocusChanged(boolean, number, Rect): void
isFocusable
Signature
declare class View {
isFocusable(): void
}
Description
Returns whether this View is currently able to take focus.
isFocusableInTouchMode
Signature
declare class View {
isFocusableInTouchMode(): void
}
Description
When a view is focusable, it may not want to take focus when in touch mode.
isFocused
Signature
declare class View {
isFocused(): void
}
Description
Returns true if this view has focus.
invalidateOutline
Signature
declare class View {
invalidateOutline(): void
}
Description
Called to rebuild this View's Outline from its outline provider
removeCallbacks
Signature
declare class View {
removeCallbacks(): void
}
Description
Removes the specified Runnable from the message queue.
scrollTo
Signature
declare class View {
scrollTo(): void
}
Description
Set the scrolled position of your view.
scrollBy
Signature
declare class View {
scrollBy(): void
}
Description
Move the scrolled position of your view.
getOutlineProvider
Signature
declare class View {
getOutlineProvider(): void
}
Description
Returns the currentViewOutlineProvider
of the view, which generates the Outline that defines the shape of the shadow it casts, and enables outline clipping.
onAttachedToWindow
Signature
declare class View {
onAttachedToWindow(): void
}
Description
This is called when the view is attached to a window.
onDetachedFromWindow
Signature
declare class View {
onDetachedFromWindow(): void
}
Description
This is called when the view is detached from a window.
onDraw
Signature
declare class View {
onDraw(canvas: Canvas): void
}
Description
Implement this to do your drawing.
onMeasure
Signature
declare class View {
onMeasure(widthMeasureSpec: number, heightMeasureSpec: number):void
}
Description
Measure the view and its content to determine the measured width and the measured height. This method is invoked by and should be overridden by subclasses to provide accurate and efficient measurement of their contents.measure(int, int)
CONTRACT: When overriding this method, you must call to store the measured width and height of this view. Failure to do so will trigger an , thrown by . Calling the superclass' is a valid use.setMeasuredDimension(int, int)
IllegalState Exceptionmeasure(int, int)
onMeasure(int, int)
The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec. Subclasses should override to provide better measurements of their content.onMeasure(int, int)
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 ( and ).getSuggestedMinimumHeight()
getSuggestedMinimumWidth()
onLayout
Signature
declare class View {
onLayout(changed: boolean, left: number, top: number, right: number, bottom: number): void
}
Description
Called from layout when this view should assign a size and position to each of its children. Derived classes with children should override this method and call layout on each of their children.
getAlpha
Signature
declare class View {
getAlpha(): number
}
Description
The opacity of the view. This is a value from 0 to 1, where 0 means the view is completely transparent and 1 means the view is completely opaque
getWidth
Signature
declare class View {
getWidth(): number
}
Description
Return the width of your view.
getHeight
Signature
declare class View {
getHeight(): number
}
Description
Return the height of your view.
getMatrix
Signature
declare class View {
getMatrix(): Matrix
}
Description
The transform matrix of this view, which is calculated based on the current rotation, scale, and pivot properties.
getId
Signature
declare class View {
getId(): number
}
Description
Returns this view's identifier.
createViewQuery
Signature
declare class View {
createViewQuery(): View.ViewQuery
createViewQuery(resources: Resources): View.ViewQuery
}
Description
Returns View Query.
addOnAttachStateChangeListener
Signature
declare class View {
addOnAttachStateChangeListener(l:View.OnAttachStateChangeListener): void
}
Description
Add a listener for attach state changes.
removeOnAttachStateChangeListener
Signature
declare class View {
removeOnAttachStateChangeListener(l:View.OnAttachStateChangeListener): void
}
Description
Remove a listener for attach state changes.
addOnLayoutChangeListener
Signature
declare class View {
addOnLayoutChangeListener(l:View.OnLayoutChangeListener): void
}
Description
Add a listener that will be called when the bounds of the view change due to layout processing.
removeOnLayoutChangeListener
Signature
declare class View {
removeOnLayoutChangeListener(l:View.OnLayoutChangeListener): void
}
Description
Remove a listener for layout changes.
invalidateDrawable
Signature
declare class View {
invalidateDrawable(who:Drawable): void
}
Description
Invalidates the specified Drawable.
scheduleDrawable
Signature
declare class View {
scheduleDrawable(who: Drawable, what: Runnable, when: number): void
}
Description
Schedules an action on a drawable to occur at a specified time.
unScheduleDrawable
Signature
declare class View {
unScheduleDrawable(who: Drawable, what: Runnable): void
}
Description
Cancels a scheduled action on a drawable.
getLayoutParams
Signature
declare class View {
getLayoutParams(): ViewGroup.LayoutParams
}
Description
Get the LayoutParams associated with this view.
getX
Signature
declare class View {
getX(): number
}
Description
The visual x position of this view, in pixels. This is equivalent to the property plus the current property.translationX
left
.
getY
Signature
declare class View {
getY(): number
}
Description
The visual y position of this view, in pixels. This is equivalent to the property plus the current property.translationY
top
.
getTranslationX
Signature
declare class View {
getTranslationX(): number
}
Description
The horizontal location of this view relative to its position. This position is post-layout, in addition to wherever the object's layout placed it.left
.
getTranslationY
Signature
declare class View {
getTranslationY(): number
}
Description
The vertical location of this view relative to its position. This position is post-layout, in addition to wherever the object's layout placed it.top
.
getScaleX
Signature
declare class View {
getScaleX(): number
}
Description
The amount that the view is scaled in x around the pivot point, as a proportion of the view's unscaled width. A value of 1, the default, means that no scaling is applied.
getScaleY
Signature
declare class View {
getScaleY(): number
}
Description
The amount that the view is scaled in y around the pivot point, as a proportion of the view's unscaled height. A value of 1, the default, means that no scaling is applied.
getPivotX
Signature
declare class View {
getPivotX(): number
}
Description
The x location of the point around which the view isrotated
andscaled
.
getPivotY
Signature
declare class View {
getPivotY(): number
}
Description
The y location of the point around which the view isrotated
andscaled
.
getRotation
Signature
declare class View {
getRotation(): number
}
Description
The degrees that the view is rotated around the pivot point.
getContext
Signature
declare class View {
getContext(): Context
}
Description
Returns the context the view is running in, through which it can access the current resources, etc.
getBackground
Signature
declare class View {
getBackground(): Drawable
}
Description
Gets the background drawable.
getParent
Signature
declare class View {
getParent(): ViewParent
}
Description
Gets the parent of this view.
setDrawingCacheEnabled
Signature
declare class View {
setDrawingCacheEnabled(enabled: boolean): void
}
Description
Enables or disables the drawing cache. When the drawing cache is enabled, the next call to or will draw the view in a bitmap.
setBackgroundColor
Signature
declare class View {
setBackgroundColor(color: number): void
}
Description
Sets the background color for this view.
setBackgroundDrawable
Signature
declare class View {
setBackgroundDrawable(drawable: Drawable): void
}
Description
setBackgroundDrawable(drawable: Drawable): void
setWillNotDraw
Signature
declare class View {
setWillNotDraw(willNotDraw: boolean) :void
}
Description
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 you should clear this flag.onDraw(Canvas)
setMeasuredDimension
Signature
declare class View {
setMeasuredDimension(measuredWidth: number, measuredHeight: number): void
}
Description
This method must be called by to store the measured width and measured height. Failing to do so will trigger an exception at measurement time.onMeasure(int, int)
setAlpha
Signature
declare class View {
setAlpha(alpha: number): void
}
Description
Sets the opacity of the view to a value from 0 to 1, where 0 means the view is completely transparent and 1 means the view is completely opaque.
setVisibility
Signature
declare class View {
setVisibility(visibility: number): void
}
Description
Set the visibility state of this view.
setOnClickListener
Signature
declare class View {
setOnClickListener(l: View.OnClickListener): void
}
Description
Register a callback to be invoked when this view is clicked. If this view is not clickable, it becomes clickable.
setOnTouchListener
Signature
declare class View {
setOnTouchListener(l: View.OnTouchListener): void
}
Description
Register a callback to be invoked when a touch event is sent to this view.
setPadding
Signature
declare class View {
setPadding(left: number, top: number, right: number, bottom: number): void
}
Description
Sets the padding. The view may add on the space required to display the scrollbars, depending on the style and visibility of the scrollbars.
setLayoutParams
Signature
declare class View {
setLayoutParams(params: ViewGroup.LayoutParams): void
}
Description
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. |
setRotation
Signature
declare class View {
setRotation(rotation: number): void
}
Description
Sets the degrees that the view is rotated around the pivot point. Increasing values result in clockwise rotation
setTranslationX
Signature
declare class View {
setTranslationX(translationX: number): void
}
Description
Sets the horizontal location of this view relative to itsleft
position. This effectively positions the object post-layout, in addition to wherever the object's layout placed it.
setTranslationY
Signature
declare class View {
setTranslationY(translationY: number): void
}
Description
Sets the vertical location of this view relative to itstop
position. This effectively positions the object post-layout, in addition to wherever the object's layout placed it.
setClipToOutline
Signature
declare class View {
setClipToOutline(clipToOutline: boolean): void
}
Description
Sets whether the View's Outline should be used to clip the contents of the View.
setFocusableInTouchMode
Signature
declare class View {
setFocusableInTouchMode(focusableInTouchMode: boolean): void
}
Description
Set whether this view can receive focus while in touch mode.
setOutlineProvider
Signature
declare class View {
setOutlineProvider(focusableInTouchMode: boolean): void
}
Description
Sets the ViewOutlineProvider of the view, which generates the Outline that defines the shape of the shadow it casts, and enables outline clipping.
setPivotX
Signature
declare class View {
setPivotX(x: number): void
}
Description
Sets the x location of the point around which the view isrotated
andscaled
.
setPivotY
Signature
declare class View {
setPivotY(y: number): void
}
Description
Sets the y location of the point around which the view isrotated
andscaled
.
setScaleX
Signature
declare class View {
setScaleX(x: number): number
}
Description
Sets the x location of the point around which the view isrotated
andscaled
.
setScaleY
Signature
declare class View {
setScaleY(y: number): number
}
Description
Sets the y location of the point around which the view isrotated
andscaled
.
setFocusable
Signature
declare class View {
setFocusable(focusable: boolean): void
}
Description
Set whether this view can receive the focus.
setOnTouchListener
Signature
declare class View {
setOnTouchListener(l: View.OnTouchListener): void
}
Description
Register a callback to be invoked when a touch event is sent to this view.
setOnKeyListener
Signature
declare class View {
setOnKeyListener(l: View.OnKeyListener): void
}
Description
Register a callback to be invoked when a hardware key is pressed in this view.
setOnFinishInflateListener
Signature
declare class View {
setOnFinishInflateListener(l:View.OnFinishInflateListener): void
}
Description
Finalize inflating a view from XML.
setOnClickListener
Signature
declare class View {
setOnClickListener(l: View.OnClickListener): void
}
Description
Register a callback to be invoked when this view is clicked.
setOnGenericMotionListener
Signature
declare class View {
setOnGenericMotionListener(l: View.OnGenericMotionListener): void
}
Description
Register a callback to be invoked when a generic motion event is sent to this view.
View.ViewQuery
ViewQuery
interface ViewQuery { }
Instance Method
findViewById
Signature
declare class ViewQuery {
findViewById(id: string):View
}
Description
Find view instances through ID.
findViewByTag
Signature
declare class ViewQuery {
findViewByTag(tag: string):View
}
Description
Find view instances through Tag.
View.MeasureSpec
MeasureSpec
interface MeasureSpec { }
Static Property
UNSPECIFIED
Type
declare class MeasureSpec {
static UNSPECIFIED: number;
}
Description
Measure specification mode: The parent has not imposed any constraint on the child.
EXACTLY
Type
declare class MeasureSpec {
static EXACTLY: number;
}
Description
Measure specification mode: The parent has determined an exact size for the child.
AT_MOST
Type
declare class MeasureSpec {
static AT_MOST: number;
}
Description
Measure specification mode: The child can be as large as it wants up to the specified size.
Instance Method
makeMeasureSpec
Signature
declare class MeasureSpec {
makeMeasureSpec(size: number, mode: number):number
}
Description
Creates a measure specification based on the supplied size and mode.
getMode
Signature
declare class MeasureSpec {
getMode(measureSpec: number):number
}
Description
Extracts the mode from the supplied measure specification.
getSize
Signature
declare class MeasureSpec {
getSize(measureSpec: number):number
}
Description
Extracts the size from the supplied measure specification.
View.OnAttachStateChangeListener
OnAttachStateChangeListener
interface OnAttachStateChangeListener {}
Instance Method
onViewAttachedToWindow
Signature
declare class OnAttachStateChangeListener {
onViewAttachedToWindow(v: View):number
}
Description
Called when the view is attached to a window.
onViewDetachedFromWindow
Signature
declare class OnAttachStateChangeListener {
gonViewDetachedFromWindow(v: View):number
}
Description
ECalled when the view is detached to a window.
View.OnTouchListener
OnTouchListener
interface OnTouchListener {}
Instance Method
OnTouchListener
Signature
declare interface OnTouchListener {
onTouch(v: View, event: MotionEvent):boolean
}
Description
Called when a touch event is dispatched to a view.
View.OnClickListener
OnClickListener
interface OnClickListener {}
Instance Method
OnClickListener
Signature
declare interface OnClickListener {
onClick(v: View):boolean
}
Description
Called when a view has been clicked.
View.OnHoverListener
OnHoverListener
interface OnHoverListener {}
Instance Method
onHover
Signature
declare interface OnHoverListener {
onHover(v: View, event: MotionEvent):boolean
}
Description
Called when a hover event is dispatched to a view.
View.OnKeyListener
OnKeyListener
interface OnKeyListener {}
Instance Method
onKey
Signature
declare interface OnKeyListener {
onKey(v: View, keyCode: number, event: KeyEvent):boolean
}
Description
Called when a hardware key is dispatched to a view.
View.OnFocusChangeListener
OnFocusChangeListener
interface OnFocusChangeListener {}
Instance Method
onFocusChange
Signature
declare interface OnFocusChangeListener {
onFocusChange(v: View, hasFocus: boolean):void
}
Description
Called when the focus state of a view has changed.
View.OnGenericMotionListener
OnGenericMotionListener
interface OnGenericMotionListener {}
Instance Method
onGenericMotion
Signature
declare interface onGenericMotion {
onGenericMotion(v: View, event: MotionEvent): boolean
}
Description
Called when a generic motion event is dispatched to a view.
View.OnLayoutChangeListener
OnLayoutChangeListener
interface OnLayoutChangeListener {}
Instance Method
onLayoutChange
Signature
declare interface onLayoutChange {
onLayoutChange(v: View, left: number, top: number, right: number, bottom: number, oldLeft: number, oldTop: number, oldRight: number, oldBottom: number): void
}
Description
Called when the layout bounds of a view changes due to layout processing.
View.OnFinishInflateListener
OnFinishInflateListener
interface OnFinishInflateListener {}
Instance Method
onViewFinishInflate
Signature
declare interface OnFinishInflateListener {
onViewFinishInflate(v: View): void
}
Description
Called after a view and all of its children has been inflated from XML.