ViewStructure | API reference | Android Developers (original) (raw)
public abstract class ViewStructureextends [Object](/reference/java/lang/Object) ``
ViewStructure is a container for storing additional per-view data generated by [View.onProvideStructure](/reference/android/view/View#onProvideStructure%28android.view.ViewStructure%29) and [View.onProvideAutofillStructure](/reference/android/view/View#onProvideAutofillStructure%28android.view.ViewStructure,%20int%29).
To learn more about using Autofill in your app, read theAutofill Framework guides.
Summary
| Nested classes | |
|---|---|
| class | ViewStructure.HtmlInfo Simplified representation of the HTML properties of a node that represents an HTML element. |
| Constants | |
|---|---|
| String | EXTRA_VIRTUAL_STRUCTURE_TYPE Key used for writing the type of the view that generated the virtual structure of its children. |
| String | EXTRA_VIRTUAL_STRUCTURE_VERSION_NUMBER Key used for specifying the version of the view that generated the virtual structure for itself and its childrenFor example, if the virtual structure is generated by a webview of version "104.0.5112.69", then the value should be "104.0.5112.69" |
| Public constructors |
|---|
| ViewStructure() |
| Public methods | |
|---|---|
| abstract int | addChildCount(int num) Add to this view's child count. |
| abstract void | asyncCommit() Call when done populating a ViewStructure returned byasyncNewChild(int). |
| abstractViewStructure | asyncNewChild(int index) Like newChild(int), but allows the caller to asynchronously populate the returned child. |
| void | clearCredentialManagerRequest() Clears the credential request previously set throughViewStructure.setPendingCredentialRequest(GetCredentialRequest,OutcomeReceiver) |
| abstractAutofillId | getAutofillId() Gets the AutofillId associated with this node. |
| abstract int | getChildCount() Return the child count as set by setChildCount(int). |
| abstractBundle | getExtras() Get extra data associated with this view structure; the returned Bundle is mutable, allowing you to view and modify its contents. |
| abstractCharSequence | getHint() Retrieve the last hint set by setHint(CharSequence). |
| OutcomeReceiver<GetCredentialResponse, GetCredentialException> | getPendingCredentialCallback() Gets the callback associated with this node. |
| GetCredentialRequest | getPendingCredentialRequest() Gets the GetCredentialRequest associated with this node. |
| abstractCharSequence | getText() Retrieve the last setText(CharSequence). |
| abstract int | getTextSelectionEnd() Retrieve the last selection end set by setText(CharSequence,int,int). |
| abstract int | getTextSelectionStart() Retrieve the last selection start set by setText(CharSequence,int,int). |
| abstract boolean | hasExtras() Returns true if getExtras() has been used to create extra content. |
| abstractViewStructure | newChild(int index) Create a new child ViewStructure in this view, putting into the list of children at index. |
| abstractViewStructure.HtmlInfo.Builder | newHtmlInfoBuilder(String tagName) Creates a new HtmlInfo.Builder for the given HTML tag. |
| abstract void | setAccessibilityFocused(boolean state) Set the accessibility focused state of this view, as perView.isAccessibilityFocused(). |
| abstract void | setActivated(boolean state) Set the activated state of this view, as per View.isActivated(). |
| abstract void | setAlpha(float alpha) Set an alpha transformation that is applied to this view, as perView.getAlpha(). |
| abstract void | setAutofillHints(String[] hint) Sets the a hints that helps the autofill service to select the appropriate data to fill the view. |
| abstract void | setAutofillId(AutofillId id) Sets the AutofillId associated with this node. |
| abstract void | setAutofillId(AutofillId parentId, int virtualId) Sets the AutofillId for this virtual node. |
| abstract void | setAutofillOptions(CharSequence[] options) Sets the options that can be used to autofill this node. |
| abstract void | setAutofillType(int type) Sets the View.getAutofillType() that can be used to autofill this node. |
| abstract void | setAutofillValue(AutofillValue value) Sets the AutofillValue representing the current value of this node. |
| abstract void | setCheckable(boolean state) Set the checkable state of this view, such as whether it implements theCheckable interface. |
| abstract void | setChecked(boolean state) Set the checked state of this view, such asCheckable.isChecked(). |
| abstract void | setChildCount(int num) Set the number of children of this view, which defines the range of indices you can use with newChild(int) and asyncNewChild(int). |
| abstract void | setClassName(String className) Set the class name of the view, as perView.getAccessibilityClassName(). |
| abstract void | setClickable(boolean state) Set the clickable state of this view, as per View.isClickable(). |
| abstract void | setContentDescription(CharSequence contentDescription) Set the content description of the view, as perView.getContentDescription(). |
| abstract void | setContextClickable(boolean state) Set the context clickable state of this view, as perView.isContextClickable(). |
| abstract void | setDataIsSensitive(boolean sensitive) Sets whether the data on this node is sensitive; if it is, then its content (text, autofill value, etc..) is striped before calls to AutofillService.onFillRequest(android.service.autofill.FillRequest, android.os.CancellationSignal, android.service.autofill.FillCallback). |
| abstract void | setDimens(int left, int top, int scrollX, int scrollY, int width, int height) Set the basic dimensions of this view. |
| abstract void | setElevation(float elevation) Set the visual elevation (shadow) of the view, as perView.getZ(). |
| abstract void | setEnabled(boolean state) Set the enabled state of this view, as per View.isEnabled(). |
| abstract void | setFocusable(boolean state) Set the focusable state of this view, as per View.isFocusable(). |
| abstract void | setFocused(boolean state) Set the focused state of this view, as per View.isFocused(). |
| abstract void | setHint(CharSequence hint) 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. |
| void | setHintIdEntry(String entryName) Sets the identifier used to set the hint associated with this view. |
| abstract void | setHtmlInfo(ViewStructure.HtmlInfo htmlInfo) Sets the HTML properties of this node when it represents an HTML element. |
| abstract void | setId(int id, String packageName, String typeName, String entryName) Set the identifier for this view. |
| void | setImportantForAutofill(int mode) Sets the importantForAutofill mode of the view associated with this node. |
| abstract void | setInputType(int inputType) Sets the InputType bits of this node. |
| abstract void | setLocaleList(LocaleList localeList) Sets the the list of locales associated with this node. |
| abstract void | setLongClickable(boolean state) Set the long clickable state of this view, as perView.isLongClickable(). |
| void | setMaxTextEms(int maxEms) Sets the maximum width in ems of the text associated with this view, when supported. |
| void | setMaxTextLength(int maxLength) Sets the maximum length of the text associated with this view, when supported. |
| void | setMinTextEms(int minEms) Sets the minimum width in ems of the text associated with this view, when supported. |
| abstract void | setOpaque(boolean opaque) Set the opaque state of this view, as per View.isOpaque(). |
| void | setPendingCredentialRequest(GetCredentialRequest request, OutcomeReceiver<GetCredentialResponse, GetCredentialException> callback) Sets a credential request to be fired to CredentialManager when this node is focused |
| void | setReceiveContentMimeTypes(String[] mimeTypes) Sets the MIME types accepted by this view. |
| abstract void | setSelected(boolean state) Set the selected state of this view, as per View.isSelected(). |
| abstract void | setText(CharSequence text) Set the text that is associated with this view. |
| abstract void | setText(CharSequence text, int selectionStart, int selectionEnd) Like setText(CharSequence) but with an active selection extending from selectionStart through selectionEnd. |
| void | setTextIdEntry(String entryName) Sets the identifier used to set the text associated with this view. |
| abstract void | setTextLines(int[] charOffsets, int[] baselines) Set line information for test that was previously supplied throughsetText(CharSequence). |
| abstract void | setTextStyle(float size, int fgColor, int bgColor, int style) Explicitly set default global style information for text that was previously set withsetText(CharSequence). |
| abstract void | setTransformation(Matrix matrix) Set the transformation matrix associated with this view, as perView.getMatrix(), or null if there is none. |
| abstract void | setVisibility(int visibility) Set the visibility state of this view, as perView.getVisibility(). |
| abstract void | setWebDomain(String domain) Sets the Web domain represented by this node. |
| Inherited methods |
|---|
| From class java.lang.Object Object clone() Creates and returns a copy of this object. boolean equals(Object obj) Indicates whether some other object is "equal to" this one. void finalize() Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. finalClass<?> getClass() Returns the runtime class of this Object. int hashCode() Returns a hash code value for the object. final void notify() Wakes up a single thread that is waiting on this object's monitor. final void notifyAll() Wakes up all threads that are waiting on this object's monitor. String toString() Returns a string representation of the object. final void wait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. final void wait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. final void wait() Causes the current thread to wait until it is awakened, typically by being notified or interrupted. |
Constants
public static final String EXTRA_VIRTUAL_STRUCTURE_TYPE
Key used for writing the type of the view that generated the virtual structure of its children.
For example, if the virtual structure is generated by a webview, the value would be "WebView". If the virtual structure is generated by a compose view, then the value would be "ComposeView". The value is of type String.
This value is added to mainly help with debugging purpose.
Constant Value: "android.view.extra.VIRTUAL_STRUCTURE_TYPE"
public static final String EXTRA_VIRTUAL_STRUCTURE_VERSION_NUMBER
Key used for specifying the version of the view that generated the virtual structure for itself and its children
For example, if the virtual structure is generated by a webview of version "104.0.5112.69", then the value should be "104.0.5112.69"
Constant Value: "android.view.extra.VIRTUAL_STRUCTURE_VERSION_NUMBER"
Public constructors
ViewStructure
public ViewStructure ()
Public methods
addChildCount
public abstract int addChildCount (int num)
Add to this view's child count. This increases the current child count bynum children beyond what was last set by [setChildCount(int)](/reference/android/view/ViewStructure#setChildCount%28int%29) or [addChildCount(int)](/reference/android/view/ViewStructure#addChildCount%28int%29). The index at which the new child starts in the child array is returned.
| Parameters | |
|---|---|
| num | int: The number of new children to add. |
| Returns | |
|---|---|
| int | Returns the index in the child array at which the new children start. |
getChildCount
public abstract int getChildCount ()
Return the child count as set by [setChildCount(int)](/reference/android/view/ViewStructure#setChildCount%28int%29).
| Returns |
|---|
| int |
public abstract Bundle getExtras ()
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.
| Returns |
|---|
| Bundle |
getTextSelectionStart
public abstract int getTextSelectionStart ()
Retrieve the last selection start set by [setText(CharSequence,int,int)](/reference/android/view/ViewStructure#setText%28java.lang.CharSequence,%20int,%20int%29).
| Returns |
|---|
| int |
public abstract boolean hasExtras ()
Returns true if [getExtras()](/reference/android/view/ViewStructure#getExtras%28%29) has been used to create extra content.
| Returns |
|---|
| boolean |
setAccessibilityFocused
public abstract void setAccessibilityFocused (boolean state)
Set the accessibility focused state of this view, as per[View.isAccessibilityFocused()](/reference/android/view/View#isAccessibilityFocused%28%29).
| Parameters | |
|---|---|
| state | boolean |
setActivated
public abstract void setActivated (boolean state)
Set the activated state of this view, as per [View.isActivated()](/reference/android/view/View#isActivated%28%29).
| Parameters | |
|---|---|
| state | boolean |
setAlpha
public abstract void setAlpha (float alpha)
Set an alpha transformation that is applied to this view, as per[View.getAlpha()](/reference/android/view/View#getAlpha%28%29). Value ranges from 0 (completely transparent) to 1 (completely opaque); the default is 1, which means no transformation.
| Parameters | |
|---|---|
| alpha | float |
setAutofillHints
public abstract void setAutofillHints (String[] hint)
Sets the a hints that helps the autofill service to select the appropriate data to fill the view.
| Parameters | |
|---|---|
| hint | String: This value may be null. |
setAutofillId
public abstract void setAutofillId (AutofillId id)
Sets the [AutofillId](/reference/android/view/autofill/AutofillId) associated with this node.
| Parameters | |
|---|---|
| id | AutofillId: This value cannot be null. |
setAutofillId
public abstract void setAutofillId (AutofillId parentId, int virtualId)
Sets the [AutofillId](/reference/android/view/autofill/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 onView.autofill(android.util.SparseArray). |
setAutofillOptions
public abstract void setAutofillOptions (CharSequence[] options)
Sets the options that can be used to autofill this node.
Typically used by nodes whose [View.getAutofillType()](/reference/android/view/View#getAutofillType%28%29) is a list to indicate the meaning of each possible value in the list.
| Parameters | |
|---|---|
| options | CharSequence |
setAutofillValue
public abstract void setAutofillValue (AutofillValue value)
Sets the [AutofillValue](/reference/android/view/autofill/AutofillValue) representing the current value of this node.
| Parameters | |
|---|---|
| value | AutofillValue |
setCheckable
public abstract void setCheckable (boolean state)
Set the checkable state of this view, such as whether it implements the[Checkable](/reference/android/widget/Checkable) interface.
| Parameters | |
|---|---|
| state | boolean |
setChecked
public abstract void setChecked (boolean state)
Set the checked state of this view, such as[Checkable.isChecked()](/reference/android/widget/Checkable#isChecked%28%29).
| Parameters | |
|---|---|
| state | boolean |
setChildCount
public abstract void setChildCount (int num)
Set the number of children of this view, which defines the range of indices you can use with [newChild(int)](/reference/android/view/ViewStructure#newChild%28int%29) and [asyncNewChild(int)](/reference/android/view/ViewStructure#asyncNewChild%28int%29). Calling this method again resets all of the child state of the view, removing any children that had previously been added.
| Parameters | |
|---|---|
| num | int |
setClickable
public abstract void setClickable (boolean state)
Set the clickable state of this view, as per [View.isClickable()](/reference/android/view/View#isClickable%28%29).
| Parameters | |
|---|---|
| state | boolean |
setContentDescription
public abstract void setContentDescription (CharSequence contentDescription)
Set the content description of the view, as per[View.getContentDescription()](/reference/android/view/View#getContentDescription%28%29).
| Parameters | |
|---|---|
| contentDescription | CharSequence |
setContextClickable
public abstract void setContextClickable (boolean state)
Set the context clickable state of this view, as per[View.isContextClickable()](/reference/android/view/View#isContextClickable%28%29).
| Parameters | |
|---|---|
| state | boolean |
setDataIsSensitive
public abstract void setDataIsSensitive (boolean sensitive)
Sets whether the data on this node is sensitive; if it is, then its content (text, autofill value, etc..) is striped before calls to [AutofillService.onFillRequest(android.service.autofill.FillRequest, android.os.CancellationSignal, android.service.autofill.FillCallback)](/reference/android/service/autofill/AutofillService#onFillRequest%28android.service.autofill.FillRequest,%20android.os.CancellationSignal,%20android.service.autofill.FillCallback%29).
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[AutofillService.onSaveRequest(android.service.autofill.SaveRequest, android.service.autofill.SaveCallback)](/reference/android/service/autofill/AutofillService#onSaveRequest%28android.service.autofill.SaveRequest,%20android.service.autofill.SaveCallback%29) 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.
| Parameters | |
|---|---|
| sensitive | boolean |
setDimens
public abstract void setDimens (int left, int top, int scrollX, int scrollY, int width, int height)
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
public abstract void setElevation (float elevation)
Set the visual elevation (shadow) of the view, as per[View.getZ()](/reference/android/view/View#getZ%28%29). 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.
| Parameters | |
|---|---|
| elevation | float |
setEnabled
public abstract void setEnabled (boolean state)
Set the enabled state of this view, as per [View.isEnabled()](/reference/android/view/View#isEnabled%28%29).
| Parameters | |
|---|---|
| state | boolean |
setFocusable
public abstract void setFocusable (boolean state)
Set the focusable state of this view, as per [View.isFocusable()](/reference/android/view/View#isFocusable%28%29).
| Parameters | |
|---|---|
| state | boolean |
setFocused
public abstract void setFocused (boolean state)
Set the focused state of this view, as per [View.isFocused()](/reference/android/view/View#isFocused%28%29).
| Parameters | |
|---|---|
| state | boolean |
setHint
public abstract void setHint (CharSequence hint)
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.
| Parameters | |
|---|---|
| hint | CharSequence |
setHintIdEntry
public void setHintIdEntry (String entryName)
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
public abstract void setHtmlInfo (ViewStructure.HtmlInfo htmlInfo)
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
public abstract void setId (int id, String packageName, String typeName, String entryName)
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
public abstract void setInputType (int inputType)
Sets the [InputType](/reference/android/text/InputType) bits of this node.
| Parameters | |
|---|---|
| inputType | int: inputType bits as defined by InputType. |
setLocaleList
public abstract void setLocaleList (LocaleList localeList)
Sets the the list of locales associated with this node.
| Parameters | |
|---|---|
| localeList | LocaleList |
setLongClickable
public abstract void setLongClickable (boolean state)
Set the long clickable state of this view, as per[View.isLongClickable()](/reference/android/view/View#isLongClickable%28%29).
| Parameters | |
|---|---|
| state | boolean |
setMaxTextEms
public void setMaxTextEms (int maxEms)
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.
| Parameters | |
|---|---|
| maxEms | int |
setMaxTextLength
public void setMaxTextLength (int maxLength)
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.
| Parameters | |
|---|---|
| maxLength | int |
setMinTextEms
public void setMinTextEms (int minEms)
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.
| Parameters | |
|---|---|
| minEms | int |
setOpaque
public abstract void setOpaque (boolean opaque)
Set the opaque state of this view, as per [View.isOpaque()](/reference/android/view/View#isOpaque%28%29).
| Parameters | |
|---|---|
| opaque | boolean |
setReceiveContentMimeTypes
public void setReceiveContentMimeTypes (String[] mimeTypes)
Sets the MIME types accepted by this view. See [View.getReceiveContentMimeTypes()](/reference/android/view/View#getReceiveContentMimeTypes%28%29).
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 | String: This value may be null. |
setSelected
public abstract void setSelected (boolean state)
Set the selected state of this view, as per [View.isSelected()](/reference/android/view/View#isSelected%28%29).
| Parameters | |
|---|---|
| state | boolean |
setText
public abstract void setText (CharSequence text)
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.
| Parameters | |
|---|---|
| text | CharSequence |
setText
public abstract void setText (CharSequence text, int selectionStart, int selectionEnd)
Like [setText(CharSequence)](/reference/android/view/ViewStructure#setText%28java.lang.CharSequence%29) but with an active selection extending from selectionStart through selectionEnd.
| Parameters | |
|---|---|
| text | CharSequence |
| selectionStart | int |
| selectionEnd | int |
setTextIdEntry
public void setTextIdEntry (String entryName)
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
public abstract void setTextLines (int[] charOffsets, int[] baselines)
Set line information for test that was previously supplied through[setText(CharSequence)](/reference/android/view/ViewStructure#setText%28java.lang.CharSequence%29). 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 | int: The offset in to setText(CharSequence) where a line starts. |
| baselines | int: The baseline where the line is drawn on screen. |
setTextStyle
public abstract void setTextStyle (float size, int fgColor, int bgColor, int style)
Explicitly set default global style information for text that was previously set with[setText(CharSequence)](/reference/android/view/ViewStructure#setText%28java.lang.CharSequence%29).
| 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 AssistStructure.ViewNode. |
setTransformation
public abstract void setTransformation (Matrix matrix)
Set the transformation matrix associated with this view, as per[View.getMatrix()](/reference/android/view/View#getMatrix%28%29), or null if there is none.
| Parameters | |
|---|---|
| matrix | Matrix |
setVisibility
public abstract void setVisibility (int visibility)
Set the visibility state of this view, as per[View.getVisibility()](/reference/android/view/View#getVisibility%28%29).
| Parameters | |
|---|---|
| visibility | int |
setWebDomain
public abstract void setWebDomain (String domain)
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. |