Interface IView
interface IView
Extends com.amazon.apmf.IStandard
IView interface defines common behaviour for all the UI components.
IView components are the fundamental building blocks of application user interface and defines behaviour common to
all components. It handles interactions like key event, pointer event on the component. All other UI components like
ITextView, IImageView, IScrollableView are basic sub interfaces of IView that UI Kit provides. All the functions of this class
should be called from the UI thread.
Methods
addLifecycleListener()
This method adds view listener and returns a subscription object related to it. This method adds view listener which is responsible to maintain lifecycle of Views.com.amazon.apmf.ISubscription*addLifecycleListener(IViewLifecycleListener*viewListener)
Parameters
viewListener
IViewLifecycleListener* — Required
Pointer to an instance of IViewLifecycleListener.
Returns
com.amazon.apmf.ISubscription*
ISubscription object related to the listener
addPointerEventListener()
This method adds pointer event listener and returns a subscription object related to it. Pointer events are used to track click or touch events on screen.com.amazon.apmf.ISubscription*addPointerEventListener(IPointerEventListener*pointerEventListener)
Parameters
pointerEventListener
IPointerEventListener* — Required
Pointer to an instance of IPointerEventListener.
Returns
com.amazon.apmf.ISubscription*
ISubscription object related to the listener
addKeyEventListener()
This method adds key event listener and returns a subscription object related to it. Key events are used for tracking hardware button presses on device (keyboard, remote, physical button on device)com.amazon.apmf.ISubscription*addKeyEventListener(IKeyEventListener*keyEventListener)
Parameters
keyEventListener
IKeyEventListener* — Required
Pointer to an instance of IKeyEventListener.
Returns
com.amazon.apmf.ISubscription*
ISubscription object related to the listener
addChild()
This method adds view as child of current viewvoidaddChild(IView*view)
Parameters
view
IView* — Required
IView object.
addChildAtIndex()
This method adds view at specific index as child of current viewvoidaddChildAtIndex(IView*view,i32index)
Parameters
view
IView* — Required
IView object.
index
i32 — Required
index of child view where view should be added
removeChild()
This method removes view from child of current viewvoidremoveChild(IView*view)
Parameters
view
IView* — Required
IView object.
removeChildAtIndex()
This method removes view at specific index from child of current viewvoidremoveChildAtIndex(i32index)
Parameters
index
i32 — Required
index of child view which is to be removed
setSize()
This method sets the size of viewvoidsetSize(com.amazon.kepler.uitoolkit.graphics.Sizesize)
Parameters
size
com.amazon.kepler.uitoolkit.graphics.Size — Required
Size of view.
setOffset()
This method sets the offset of view relative to top-left corner of parent’s viewvoidsetOffset(com.amazon.kepler.uitoolkit.graphics.Pointpoint)
Parameters
point
com.amazon.kepler.uitoolkit.graphics.Point — Required
Offset of view.
getChildren()
Returns an array of the direct child views of this view.IView*[]getChildren()
Returns
IView*[]
An array containing the direct child views of this view, or an empty array if
this view has no children.
getParent()
Returns the parent view of this view. Each view must have a single parent except for the root view, which has no parent. This link is set whenever this view is added as a child under any view.IView?getParent()
Returns
IView?
The return value is optional and might be absent.
IView pointer to the parent of this view. It may be null if this view
has not been added as a child to any view.
getSize()
com.amazon.kepler.uitoolkit.graphics.Size getSize()
Returns the size of this view.
Returns
com.amazon.kepler.uitoolkit.graphics.Size
Size of the view. If the user has not called setSize, the view will inherit size from its
parent. The root view will inherit its size from window dimensions.
getOffset()
com.amazon.kepler.uitoolkit.graphics.Point getOffset()
This method returns the offset of view relative to top-left corner of parent’s view.
Returns
com.amazon.kepler.uitoolkit.graphics.Point
Point Offset of view. By default the offset will be {0, 0}.
getTestId()
string getTestId()
This method returns the test id set by the user on this view.
See also- IView::setTestId.
Returns
string
string Test id set by the user. By default this will return empty string.
setTestId()
This method sets the test id on this view. This sets a property in accessibility information to emit test the id set by the consumer. This can also be used for debugging purposes by the developer.voidsetTestId(stringid)
Parameters
id
string — Required
string.
setVisibility()
Sets the given visibility to the current view.voidsetVisibility(ViewVisibilityvisibility)
Parameters
visibility
ViewVisibility — Required
ViewVisibility depicting the desired visibility.
getVisibility()
ViewVisibility getVisibility()
This API returns the current visibility of the view. The default visibility of the view will be
ViewVisibility::VISIBLE.
Returns
ViewVisibility
ViewVisibility.
isAttachedToWindow()
bool isAttachedToWindow()
Returns if the current view is attached to the view tree in the current window.
Returns
bool
bool True if the view is attached in the view tree.
getRootView()
Return the root view of the view hierarchy if attached to the view tree, otherwise will return null value.IView?getRootView()
Returns
IView?
The return value is optional and might be absent.
IView.
addSizeChangedListener()
Adds a size change listener whenever the size of the current view is changed.com.amazon.apmf.ISubscription*addSizeChangedListener(ISizeChangeListener*sizeChangedListener)
Parameters
sizeChangedListener
ISizeChangeListener* — Required
ISizeChangeListener.
Returns
com.amazon.apmf.ISubscription*
ISubscription to cancel (remove) the listener.
getViewDelegate()
Returns the view delegate attached to this view during creation. The view delegate can be casted to the custom implementation of the developer.IViewDelegate?getViewDelegate()
Returns
IViewDelegate?
The return value is optional and might be absent.
A valid IViewDelegate if the view is created using IViewModule::makeViewWithDelegate.
Otherwise returns null.
addAxisEventListener()
This method adds axis event listener and returns a subscription object related to it. Axis events are used to track axis value for an event.com.amazon.apmf.ISubscription*addAxisEventListener(IAxisEventListener*axisEventListener)
Parameters
axisEventListener
IAxisEventListener* — Required
Pointer to an instance of IAxisEventListener.
Returns
com.amazon.apmf.ISubscription*
ISubscription object related to the listener
getWindowEventDispatcher()
Gets theIWindowEventDispatcher?getWindowEventDispatcher()
IWindowEventDispatcher.
Returns
IWindowEventDispatcher?
The return value is optional and might be absent.
The IWindowEventDispatcher associated with the IUIWindow on which this view is attached to, or
nullptr if this view is not currently attached to a window.
setBackgroundColor()
Sets the background color. This function sets the background color. Default background color is Color::Transparent.voidsetBackgroundColor(com.amazon.kepler.uitoolkit.graphics.Color*backgroundColor)
Parameters
backgroundColor
com.amazon.kepler.uitoolkit.graphics.Color* — Required
The Color struct defining the background color.
getBackgroundColor()
com.amazon.kepler.uitoolkit.graphics.Color getBackgroundColor()
Returns the background color.
This function retrieves the background color.
Returns
com.amazon.kepler.uitoolkit.graphics.Color
The Color struct defining the background color.
setOpacity()
Sets the opacity. This function sets the opacity. Opacity can be in the range 0.0 to 1.0, where 0.0 represents totally transparent and 1.0 represents totally opaque. Default opacity is 1.0.voidsetOpacity(floatopacity)
Parameters
opacity
float — Required
A float value representing the opacity level (0.0 to 1.0).
getOpacity()
float getOpacity()
Returns the opacity.
This function retrieves the opacity.
Returns
float
A float value representing the opacity level (0.0 to 1.0).
setShadow()
Sets the shadow configuration. This function sets the shadow configuration.voidsetShadow(com.amazon.kepler.uitoolkit.graphics.IShadow*shadow)
Parameters
shadow
com.amazon.kepler.uitoolkit.graphics.IShadow* — Required
The IShadow object defining the shadow properties.
getShadow()
Returns the shadow configuration. This function retrieves the shadow configuration.com.amazon.kepler.uitoolkit.graphics.IShadow*getShadow()
Returns
com.amazon.kepler.uitoolkit.graphics.IShadow*
The IShadow object defining the shadow properties.
setTransformationMatrix()
Sets the transformation matrix. This function sets the transformation matrix. The matrix is applied relative to the view’s top-left corner (origin). ThevoidsetTransformationMatrix(com.amazon.kepler.uitoolkit.graphics.AffineMatrix*matrix)
AffineMatrix can be used to achieve translate, scale, rotate, and pivot
transformations by composing the appropriate matrix values. To apply a transform around
a custom pivot point (ox, oy), wrap the transform with a translate/untranslate:
finalMatrix = translate(ox, oy) * transform * translate(-ox, -oy).
For detailed documentation and examples of how to construct matrices for common
transformations (translate, scale, rotate, skew, and their combinations), refer to
SkMatrix
Parameters
matrix
com.amazon.kepler.uitoolkit.graphics.AffineMatrix* — Required
A AffineMatrix object representing the transformation matrix.
getTransformationMatrix()
com.amazon.kepler.uitoolkit.graphics.AffineMatrix getTransformationMatrix()
Returns the transformation matrix.
This function retrieves the transformation matrix.
Returns
com.amazon.kepler.uitoolkit.graphics.AffineMatrix
The AffineMatrix object representing the transformation matrix.
setBorderColor()
Sets the color for the Border. This method sets the color for the Border. Default border color for all edges is Color::Black.voidsetBorderColor(BorderColor*color)
Parameters
color
BorderColor* — Required
The BorderColor struct representing the border color to be set.
getBorderColor()
BorderColor getBorderColor()
Returns the color of the border.
This method retrieves the color of the border.
Returns
BorderColor
The BorderColor struct representing the border color.
setBorderWidth()
Sets the width for the Border. This method sets the width for the Border. Default border width for all edges is 0.0.voidsetBorderWidth(BorderWidth*width)
Parameters
width
BorderWidth* — Required
The BorderWidth struct representing the border width to be set.
getBorderWidth()
BorderWidth getBorderWidth()
Returns the width of the border.
This method retrieves the width of the border.
Returns
BorderWidth
The BorderWidth struct representing the border width.
setBorderRadius()
Sets the corner radius for the Border. This method sets the corner radius for the Border. Default border radius for all corners is 0.0.voidsetBorderRadius(BorderRadius*radius)
Parameters
radius
BorderRadius* — Required
A BorderRadius struct representing the border radius to be set.
getBorderRadius()
BorderRadius getBorderRadius()
Returns the radius of the border.
This method retrieves the radius of the border, which defines the curvature of the border corners.
Returns
BorderRadius
A BorderRadius struct representing the border radius.
setBorderStyle()
Sets the style for the Border. This method sets a uniform border style across all edges. Default border style is BorderStyle::SOLID. For per-edge styling, usevoidsetBorderStyle(BorderStylestyle)
IView7::setBorderEdgeStyle.
This API and IView7::setBorderEdgeStyle both control border style
and follow last-write-wins semantics. Calling this method overrides any
per-edge styles previously set via IView7::setBorderEdgeStyle.
Conversely, a subsequent call to IView7::setBorderEdgeStyle will
override the uniform style set by this method.
Parameters
style
BorderStyle — Required
The BorderStyle representing the desired style of the border.
getBorderStyle()
BorderStyle getBorderStyle()
Returns the style of the border.
This method is not intended to be used when per-edge styles have been
set via IView7::setBorderEdgeStyle. In that case, use
IView7::getBorderEdgeStyle instead.
If called when per-edge styles are set, it returns the top edge’s style.
Returns
BorderStyle
A BorderStyle representing the border style.

