# ViewStructureCompat

# ViewStructureCompat

Artifact:[androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core)  
[View Source](https://cs.android.com/search?q=file:androidx/core/view/ViewStructureCompat.java+class:androidx.core.view.ViewStructureCompat)  
Added in[1.11.0](https://developer.android.com/jetpack/androidx/releases/core#1.11.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/view/ViewStructureCompat "View this page in Java")

<br />

```
class ViewStructureCompat
```

<br />

*** ** * ** ***

Helper for accessing features in[ViewStructure](https://developer.android.com/reference/android/view/ViewStructure.html).

Currently this helper class only has features for content capture usage. Other features for Autofill are not available.

## Summary

|                                                    ### Public functions                                                    |
|----------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                              | [setClassName](https://developer.android.com/reference/kotlin/androidx/core/view/ViewStructureCompat#setClassName(java.lang.String))`(string: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`)` Set the class name of the view, as per[View.getAccessibilityClassName()](https://developer.android.com/reference/android/view/View.html#getAccessibilityClassName()).                                                                                                                                                                                                                                                                                                                                |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                              | [setContentDescription](https://developer.android.com/reference/kotlin/androidx/core/view/ViewStructureCompat#setContentDescription(java.lang.CharSequence))`(charSequence: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`)` Set the content description of the view, as per[View.getContentDescription()](https://developer.android.com/reference/android/view/View.html#getContentDescription()).                                                                                                                                                                                                                                                                                    |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                              | [setDimens](https://developer.android.com/reference/kotlin/androidx/core/view/ViewStructureCompat#setDimens(int,int,int,int,int,int))`(` ` left: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` top: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` scrollX: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` scrollY: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` width: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` height: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) `)` Set the basic dimensions of this view. |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                              | [setText](https://developer.android.com/reference/kotlin/androidx/core/view/ViewStructureCompat#setText(java.lang.CharSequence))`(charSequence: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`)` Set the text that is associated with this view.                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [ViewStructure](https://developer.android.com/reference/android/view/ViewStructure.html)                                   | `@`[RequiresApi](https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi)`(value = 23)` [toViewStructure](https://developer.android.com/reference/kotlin/androidx/core/view/ViewStructureCompat#toViewStructure())`()` Provides the[ViewStructure](https://developer.android.com/reference/android/view/ViewStructure.html)represented by this object.                                                                                                                                                                                                                                                                                                                                                            |
| `java-static `[ViewStructureCompat](https://developer.android.com/reference/kotlin/androidx/core/view/ViewStructureCompat) | `@`[RequiresApi](https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi)`(value = 23)` [toViewStructureCompat](https://developer.android.com/reference/kotlin/androidx/core/view/ViewStructureCompat#toViewStructureCompat(android.view.ViewStructure))`(contentCaptureSession: `[ViewStructure](https://developer.android.com/reference/android/view/ViewStructure.html)`)` Provides a backward-compatible wrapper for[ViewStructure](https://developer.android.com/reference/android/view/ViewStructure.html).                                                                                                                                                                                                 |

## Public functions

### setClassName

Added in[1.11.0](https://developer.android.com/jetpack/androidx/releases/core#1.11.0)  

```
fun setClassName(string: String): Unit
```

Set the class name of the view, as per[View.getAccessibilityClassName()](https://developer.android.com/reference/android/view/View.html#getAccessibilityClassName()). Compatibility behavior:

- SDK 23 and above, this method matches platform behavior.
- SDK 22 and below, this method does nothing.  

### setContentDescription

Added in[1.11.0](https://developer.android.com/jetpack/androidx/releases/core#1.11.0)  

```
fun setContentDescription(charSequence: CharSequence): Unit
```

Set the content description of the view, as per[View.getContentDescription()](https://developer.android.com/reference/android/view/View.html#getContentDescription()). Compatibility behavior:

- SDK 23 and above, this method matches platform behavior.
- SDK 22 and below, this method does nothing.  

### setDimens

Added in[1.11.0](https://developer.android.com/jetpack/androidx/releases/core#1.11.0)  

```
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](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)    | The view's left position, in pixels relative to its parent's left edge.                                                                                                                                                                                      |
| `top: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)     | The view's top position, in pixels relative to its parent's top edge.                                                                                                                                                                                        |
| `scrollX: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | How much the view's x coordinate space has been scrolled, in pixels.                                                                                                                                                                                         |
| `scrollY: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | How much the view's y coordinate space has been scrolled, in pixels.                                                                                                                                                                                         |
| `width: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)   | 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](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)  | The view's visible height, in pixels. This is the height visible on screen, not the total data height of a scrollable view. Compatibility behavior: - SDK 23 and above, this method matches platform behavior. - SDK 22 and below, this method does nothing. |

### setText

Added in[1.11.0](https://developer.android.com/jetpack/androidx/releases/core#1.11.0)  

```
fun setText(charSequence: 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. Compatibility behavior:

- SDK 23 and above, this method matches platform behavior.
- SDK 22 and below, this method does nothing.  

### toViewStructure

Added in[1.11.0](https://developer.android.com/jetpack/androidx/releases/core#1.11.0)  

```
@RequiresApi(value = 23)
fun toViewStructure(): ViewStructure
```

Provides the[ViewStructure](https://developer.android.com/reference/android/view/ViewStructure.html)represented by this object.

This method is not supported on devices running SDK \<23 since the platform class will not be available.  

|                                         Returns                                          |
|------------------------------------------------------------------------------------------|-----------------------|
| [ViewStructure](https://developer.android.com/reference/android/view/ViewStructure.html) | platform class object |

|                                                                             See also                                                                             |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [toViewStructureCompat](https://developer.android.com/reference/kotlin/androidx/core/view/ViewStructureCompat#toViewStructureCompat(android.view.ViewStructure)) |   |

### toViewStructureCompat

Added in[1.11.0](https://developer.android.com/jetpack/androidx/releases/core#1.11.0)  

```
@RequiresApi(value = 23)
java-static fun toViewStructureCompat(contentCaptureSession: ViewStructure): ViewStructureCompat
```

Provides a backward-compatible wrapper for[ViewStructure](https://developer.android.com/reference/android/view/ViewStructure.html).

This method is not supported on devices running SDK \<23 since the platform class will not be available.  

|                                                    Parameters                                                     |
|-------------------------------------------------------------------------------------------------------------------|------------------------|
| `contentCaptureSession: `[ViewStructure](https://developer.android.com/reference/android/view/ViewStructure.html) | platform class to wrap |

|                                                   Returns                                                    |
|--------------------------------------------------------------------------------------------------------------|---------------|
| [ViewStructureCompat](https://developer.android.com/reference/kotlin/androidx/core/view/ViewStructureCompat) | wrapped class |