Added in API level 23

ViewStructure

abstract class ViewStructure
kotlin.Any
   ↳ android.view.ViewStructure

ViewStructure is a container for storing additional per-view data generated by View.onProvideStructure and View.onProvideAutofillStructure.

To learn more about using Autofill in your app, read the Autofill Framework guides.

Summary

Nested classes
abstract

Simplified representation of the HTML properties of a node that represents an HTML element.

Public constructors

Public methods
abstract Int

Add to this view's child count.

abstract Unit

Call when done populating a ViewStructure returned by asyncNewChild.

abstract ViewStructure!

Like newChild, but allows the caller to asynchronously populate the returned child.

abstract AutofillId?

Gets the AutofillId associated with this node.

abstract Int

Return the child count as set by setChildCount.

abstract Bundle!

Get extra data associated with this view structure; the returned Bundle is mutable, allowing you to view and modify its contents.

abstract CharSequence!

Retrieve the last hint set by setHint.

abstract CharSequence!

Retrieve the last setText(java.lang.CharSequence).

abstract Int

Retrieve the last selection end set by setText(java.lang.CharSequence,int,int).

abstract Int

Retrieve the last selection start set by setText(java.lang.CharSequence,int,int).

abstract Boolean

Returns true if getExtras has been used to create extra content.

abstract ViewStructure!
newChild(index: Int)

Create a new child ViewStructure in this view, putting into the list of children at index.

abstract ViewStructure.HtmlInfo.Builder!

Creates a new HtmlInfo.Builder for the given HTML tag.

abstract Unit

Set the accessibility focused state of this view, as per View.isAccessibilityFocused().

abstract Unit

Set the activated state of this view, as per View.isActivated().

abstract Unit
setAlpha(alpha: Float)

Set an alpha transformation that is applied to this view, as per View.getAlpha().

abstract Unit

Sets the a hints that helps the autofill service to select the appropriate data to fill the view.

abstract Unit

Sets the AutofillId associated with this node.

abstract Unit
setAutofillId(parentId: AutofillId, virtualId: Int)

Sets the AutofillId for this virtual node.

abstract Unit

Sets the options that can be used to autofill this node.

abstract Unit

Sets the View#getAutofillType() that can be used to autofill this node.

abstract Unit

Sets the AutofillValue representing the current value of this node.

abstract Unit

Set the checkable state of this view, such as whether it implements the android.widget.Checkable interface.

abstract Unit

Set the checked state of this view, such as Checkable.isChecked().

abstract Unit

Set the number of children of this view, which defines the range of indices you can use with newChild and asyncNewChild.

abstract Unit
setClassName(className: String!)

Set the class name of the view, as per View.getAccessibilityClassName().

abstract Unit

Set the clickable state of this view, as per View.isClickable().

abstract Unit
setContentDescription(contentDescription: CharSequence!)

Set the content description of the view, as per View.getContentDescription().

abstract Unit

Set the context clickable state of this view, as per View.isContextClickable().

abstract Unit

Sets whether the data on this node is sensitive; if it is, then its content (text, autofill value, etc..) is striped before calls to

abstract Unit
setDimens(left: Int, top: Int, scrollX: Int, scrollY: Int, width: Int, height: Int)

Set the basic dimensions of this view.

abstract Unit
setElevation(elevation: Float)

Set the visual elevation (shadow) of the view, as per View.getZ().

abstract Unit

Set the enabled state of this view, as per View.isEnabled().

abstract Unit

Set the focusable state of this view, as per View.isFocusable().

abstract Unit

Set the focused state of this view, as per View.isFocused().

abstract Unit

Set optional hint text associated with this view; this is for example the text that is shown by an EditText when it is empty to indicate to the user the kind of text to input.

open Unit
setHintIdEntry(entryName: String)

Sets the identifier used to set the hint associated with this view.

abstract Unit

Sets the HTML properties of this node when it represents an HTML element.

abstract Unit
setId(id: Int, packageName: String!, typeName: String!, entryName: String!)

Set the identifier for this view.

open Unit

Sets the importantForAutofill mode of the view associated with this node.

abstract Unit
setInputType(inputType: Int)

Sets the android.text.InputType bits of this node.

abstract Unit
setLocaleList(localeList: LocaleList!)

Sets the the list of locales associated with this node.

abstract Unit

Set the long clickable state of this view, as per View.isLongClickable().

open Unit
setMaxTextEms(maxEms: Int)

Sets the maximum width in ems of the text associated with this view, when supported.

open Unit
setMaxTextLength(maxLength: Int)

Sets the maximum length of the text associated with this view, when supported.

open Unit
setMinTextEms(minEms: Int)

Sets the minimum width in ems of the text associated with this view, when supported.

abstract Unit
setOpaque(opaque: Boolean)

Set the opaque state of this view, as per View.isOpaque().

open Unit

Sets the MIME types accepted by this view.

abstract Unit

Set the selected state of this view, as per View.isSelected().

abstract Unit

Set the text that is associated with this view.

abstract Unit
setText(text: CharSequence!, selectionStart: Int, selectionEnd: Int)

Like setText(java.lang.CharSequence) but with an active selection extending from selectionStart through selectionEnd.

open Unit
setTextIdEntry(entryName: String)

Sets the identifier used to set the text associated with this view.

abstract Unit
setTextLines(charOffsets: IntArray!, baselines: IntArray!)

Set line information for test that was previously supplied through setText(java.lang.CharSequence).

abstract Unit
setTextStyle(size: Float, fgColor: Int, bgColor: Int, style: Int)

Explicitly set default global style information for text that was previously set with #setText.

abstract Unit

Set the transformation matrix associated with this view, as per View.getMatrix(), or null if there is none.

abstract Unit
setVisibility(visibility: Int)

Set the visibility state of this view, as per View.getVisibility().

abstract Unit
setWebDomain(domain: String?)

Sets the Web domain represented by this node.

Public constructors

ViewStructure

ViewStructure()

Public methods

addChildCount

Added in API level 23
abstract fun addChildCount(num: Int): Int

Add to this view's child count. This increases the current child count by num children beyond what was last set by setChildCount or addChildCount. The index at which the new child starts in the child array is returned.

Parameters
num Int: The number of new children to add.
Return
Int Returns the index in the child array at which the new children start.

asyncCommit

Added in API level 23
abstract fun asyncCommit(): Unit

Call when done populating a ViewStructure returned by asyncNewChild.

asyncNewChild

Added in API level 23
abstract fun asyncNewChild(index: Int): ViewStructure!

Like newChild, but allows the caller to asynchronously populate the returned child. It can transfer the returned ViewStructure to another thread for it to build its content (and children etc). Once done, some thread must call asyncCommit to tell the containing ViewStructure that the async population is done.

NOTE: you must pre-allocate space for the child first, by calling either addChildCount(int) or setChildCount(int).

Return
ViewStructure! Returns an fresh ViewStructure ready to be filled in.

getAutofillId

Added in API level 26
abstract fun getAutofillId(): AutofillId?

Gets the AutofillId associated with this node.

Return
AutofillId? This value may be null.

getChildCount

Added in API level 23
abstract fun getChildCount(): Int

Return the child count as set by setChildCount.

getExtras

Added in API level 23
abstract fun getExtras(): Bundle!

Get extra data associated with this view structure; the returned Bundle is mutable, allowing you to view and modify its contents. Keys placed in the Bundle should use an appropriate namespace prefix (such as com.google.MY_KEY) to avoid conflicts.

getHint

Added in API level 23
abstract fun getHint(): CharSequence!

Retrieve the last hint set by setHint.

getText

Added in API level 23
abstract fun getText(): CharSequence!

Retrieve the last setText(java.lang.CharSequence).

getTextSelectionEnd

Added in API level 23
abstract fun getTextSelectionEnd(): Int

Retrieve the last selection end set by setText(java.lang.CharSequence,int,int).

getTextSelectionStart

Added in API level 23
abstract fun getTextSelectionStart(): Int

Retrieve the last selection start set by setText(java.lang.CharSequence,int,int).

hasExtras

Added in API level 23
abstract fun hasExtras(): Boolean

Returns true if getExtras has been used to create extra content.

newChild

Added in API level 23
abstract fun newChild(index: Int): ViewStructure!

Create a new child ViewStructure in this view, putting into the list of children at index.

NOTE: you must pre-allocate space for the child first, by calling either addChildCount(int) or setChildCount(int).

Return
ViewStructure! Returns an fresh ViewStructure ready to be filled in.

newHtmlInfoBuilder

Added in API level 26
abstract fun newHtmlInfoBuilder(tagName: String): ViewStructure.HtmlInfo.Builder!

Creates a new HtmlInfo.Builder for the given HTML tag.

Parameters
tagName String: name of the HTML tag. This value cannot be null.
Return
ViewStructure.HtmlInfo.Builder! a new builder.

setAccessibilityFocused

Added in API level 23
abstract fun setAccessibilityFocused(state: Boolean): Unit

Set the accessibility focused state of this view, as per View.isAccessibilityFocused().

setActivated

Added in API level 23
abstract fun setActivated(state: Boolean): Unit

Set the activated state of this view, as per View.isActivated().

setAlpha

Added in API level 23
abstract fun setAlpha(alpha: Float): Unit

Set an alpha transformation that is applied to this view, as per View.getAlpha(). Value ranges from 0 (completely transparent) to 1 (completely opaque); the default is 1, which means no transformation.

setAutofillHints

Added in API level 26
abstract fun setAutofillHints(hint: Array<String!>?): Unit

Sets the a hints that helps the autofill service to select the appropriate data to fill the view.

Parameters
hint Array<String!>?: This value may be null.

setAutofillId

Added in API level 26
abstract fun setAutofillId(id: AutofillId): Unit

Sets the AutofillId associated with this node.

Parameters
id AutofillId: This value cannot be null.

setAutofillId

Added in API level 26
abstract fun setAutofillId(
    parentId: AutofillId,
    virtualId: Int
): Unit

Sets the AutofillId for this virtual node.

Parameters
parentId AutofillId: id of the parent node. This value cannot be null.
virtualId Int: an opaque ID to the Android System; it's the same id used on View#autofill(android.util.SparseArray).

setAutofillOptions

Added in API level 26
abstract fun setAutofillOptions(options: Array<CharSequence!>!): Unit

Sets the options that can be used to autofill this node.

Typically used by nodes whose View#getAutofillType() is a list to indicate the meaning of each possible value in the list.

setAutofillType

Added in API level 26
abstract fun setAutofillType(type: Int): Unit

Sets the View#getAutofillType() that can be used to autofill this node.

Parameters
type Int: Value is android.view.View#AUTOFILL_TYPE_NONE, android.view.View#AUTOFILL_TYPE_TEXT, android.view.View#AUTOFILL_TYPE_TOGGLE, android.view.View#AUTOFILL_TYPE_LIST, or android.view.View#AUTOFILL_TYPE_DATE

setAutofillValue

Added in API level 26
abstract fun setAutofillValue(value: AutofillValue!): Unit

Sets the AutofillValue representing the current value of this node.

setCheckable

Added in API level 23
abstract fun setCheckable(state: Boolean): Unit

Set the checkable state of this view, such as whether it implements the android.widget.Checkable interface.

setChecked

Added in API level 23
abstract fun setChecked(state: Boolean): Unit

Set the checked state of this view, such as Checkable.isChecked().

setChildCount

Added in API level 23
abstract fun setChildCount(num: Int): Unit

Set the number of children of this view, which defines the range of indices you can use with newChild and asyncNewChild. Calling this method again resets all of the child state of the view, removing any children that had previously been added.

setClassName

Added in API level 23
abstract fun setClassName(className: String!): Unit

Set the class name of the view, as per View.getAccessibilityClassName().

setClickable

Added in API level 23
abstract fun setClickable(state: Boolean): Unit

Set the clickable state of this view, as per View.isClickable().

setContentDescription

Added in API level 23
abstract fun setContentDescription(contentDescription: CharSequence!): Unit

Set the content description of the view, as per View.getContentDescription().

setContextClickable

Added in API level 23
abstract fun setContextClickable(state: Boolean): Unit

Set the context clickable state of this view, as per View.isContextClickable().

setDataIsSensitive

Added in API level 26
abstract fun setDataIsSensitive(sensitive: Boolean): Unit

Sets whether the data on this node is sensitive; if it is, then its content (text, autofill value, etc..) is striped before calls to android.service.autofill.AutofillService#onFillRequest(android.service.autofill.FillRequest, * android.os.CancellationSignal, android.service.autofill.FillCallback).

By default, all nodes are assumed to be sensitive, and only nodes that does not have PII (Personally Identifiable Information - sensitive data such as email addresses, credit card numbers, passwords, etc...) should be marked as non-sensitive; a good rule of thumb is to mark as non-sensitive nodes whose value were statically set from resources.

Notice that the content of even sensitive nodes are sent to the service (through the android.service.autofill.AutofillService#onSaveRequest(android.service.autofill.SaveRequest, * android.service.autofill.SaveCallback) call) when the user consented to save thedata, so it is important to set the content of sensitive nodes as well, but mark them as sensitive.

Should only be set when the node is used for autofill purposes - it will be ignored when used for Assist.

setDimens

Added in API level 23
abstract fun setDimens(
    left: Int,
    top: Int,
    scrollX: Int,
    scrollY: Int,
    width: Int,
    height: Int
): Unit

Set the basic dimensions of this view.

Parameters
left Int: The view's left position, in pixels relative to its parent's left edge.
top Int: The view's top position, in pixels relative to its parent's top edge.
scrollX Int: How much the view's x coordinate space has been scrolled, in pixels.
scrollY Int: How much the view's y coordinate space has been scrolled, in pixels.
width Int: The view's visible width, in pixels. This is the width visible on screen, not the total data width of a scrollable view.
height Int: The view's visible height, in pixels. This is the height visible on screen, not the total data height of a scrollable view.

setElevation

Added in API level 23
abstract fun setElevation(elevation: Float): Unit

Set the visual elevation (shadow) of the view, as per View.getZ(). Note this is not related to the physical Z-ordering of this view relative to its other siblings (that is how they overlap when drawing), it is only the visual representation for shadowing.

setEnabled

Added in API level 23
abstract fun setEnabled(state: Boolean): Unit

Set the enabled state of this view, as per View.isEnabled().

setFocusable

Added in API level 23
abstract fun setFocusable(state: Boolean): Unit

Set the focusable state of this view, as per View.isFocusable().

setFocused

Added in API level 23
abstract fun setFocused(state: Boolean): Unit

Set the focused state of this view, as per View.isFocused().

setHint

Added in API level 23
abstract fun setHint(hint: CharSequence!): Unit

Set optional hint text associated with this view; this is for example the text that is shown by an EditText when it is empty to indicate to the user the kind of text to input.

setHintIdEntry

Added in API level 30
open fun setHintIdEntry(entryName: String): Unit

Sets the identifier used to set the hint associated with this view.

Used as metadata for fingerprinting view nodes/structures.

Should only be set when the node is used for autofill purposes - it will be ignored when used for Assist.

Parameters
entryName String: This value cannot be null.

setHtmlInfo

Added in API level 26
abstract fun setHtmlInfo(htmlInfo: ViewStructure.HtmlInfo): Unit

Sets the HTML properties of this node when it represents an HTML element.

Should only be set when the node is used for autofill purposes - it will be ignored when used for assist.

Parameters
htmlInfo ViewStructure.HtmlInfo: HTML properties. This value cannot be null.

setId

Added in API level 23
abstract fun setId(
    id: Int,
    packageName: String!,
    typeName: String!,
    entryName: String!
): Unit

Set the identifier for this view.

Parameters
id Int: The view's identifier, as per View.getId().
packageName String!: The package name of the view's identifier, or null if there is none.
typeName String!: The type name of the view's identifier, or null if there is none.
entryName String!: The entry name of the view's identifier, or null if there is none.

setInputType

Added in API level 26
abstract fun setInputType(inputType: Int): Unit

Sets the android.text.InputType bits of this node.

Parameters
inputType Int: inputType bits as defined by android.text.InputType.

setLocaleList

Added in API level 26
abstract fun setLocaleList(localeList: LocaleList!): Unit

Sets the the list of locales associated with this node.

setLongClickable

Added in API level 23
abstract fun setLongClickable(state: Boolean): Unit

Set the long clickable state of this view, as per View.isLongClickable().

setMaxTextEms

Added in API level 28
open fun setMaxTextEms(maxEms: Int): Unit

Sets the maximum width in ems of the text associated with this view, when supported.

Should only be set when the node is used for autofill purposes - it will be ignored when used for Assist.

setMaxTextLength

Added in API level 28
open fun setMaxTextLength(maxLength: Int): Unit

Sets the maximum length of the text associated with this view, when supported.

Should only be set when the node is used for autofill purposes - it will be ignored when used for Assist.

setMinTextEms

Added in API level 28
open fun setMinTextEms(minEms: Int): Unit

Sets the minimum width in ems of the text associated with this view, when supported.

Should only be set when the node is used for autofill purposes - it will be ignored when used for Assist.

setOpaque

Added in API level 26
abstract fun setOpaque(opaque: Boolean): Unit

Set the opaque state of this view, as per View.isOpaque().

setReceiveContentMimeTypes

Added in API level 31
open fun setReceiveContentMimeTypes(mimeTypes: Array<String!>?): Unit

Sets the MIME types accepted by this view. See View#getReceiveContentMimeTypes().

Should only be set when the node is used for Autofill or Content Capture purposes - it will be ignored when used for Assist.

Parameters
mimeTypes Array<String!>?: This value may be null.

setSelected

Added in API level 23
abstract fun setSelected(state: Boolean): Unit

Set the selected state of this view, as per View.isSelected().

setText

Added in API level 23
abstract fun setText(text: CharSequence!): Unit

Set the text that is associated with this view. There is no selection associated with the text. The text may have style spans to supply additional display and semantic information.

setText

Added in API level 23
abstract fun setText(
    text: CharSequence!,
    selectionStart: Int,
    selectionEnd: Int
): Unit

Like setText(java.lang.CharSequence) but with an active selection extending from selectionStart through selectionEnd.

setTextIdEntry

Added in API level 28
open fun setTextIdEntry(entryName: String): Unit

Sets the identifier used to set the text associated with this view.

Should only be set when the node is used for autofill purposes - it will be ignored when used for Assist.

Parameters
entryName String: This value cannot be null.

setTextLines

Added in API level 23
abstract fun setTextLines(
    charOffsets: IntArray!,
    baselines: IntArray!
): Unit

Set line information for test that was previously supplied through setText(java.lang.CharSequence). This provides the line breaking of the text as it is shown on screen. This function takes ownership of the provided arrays; you should not make further modification to them.

Parameters
charOffsets IntArray!: The offset in to #setText where a line starts.
baselines IntArray!: The baseline where the line is drawn on screen.

setTextStyle

Added in API level 23
abstract fun setTextStyle(
    size: Float,
    fgColor: Int,
    bgColor: Int,
    style: Int
): Unit

Explicitly set default global style information for text that was previously set with #setText.

Parameters
size Float: The size, in pixels, of the text.
fgColor Int: The foreground color, packed as 0xAARRGGBB.
bgColor Int: The background color, packed as 0xAARRGGBB.
style Int: Style flags, as defined by android.app.assist.AssistStructure.ViewNode.

setTransformation

Added in API level 23
abstract fun setTransformation(matrix: Matrix!): Unit

Set the transformation matrix associated with this view, as per View.getMatrix(), or null if there is none.

setVisibility

Added in API level 23
abstract fun setVisibility(visibility: Int): Unit

Set the visibility state of this view, as per View.getVisibility().

setWebDomain

Added in API level 26
abstract fun setWebDomain(domain: String?): Unit

Sets the Web domain represented by this node.

Typically used when the view is a container for an HTML document.

Parameters
domain String?: RFC 2396-compliant URI representing the domain. This value may be null.