# 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)

*** ** * ** ***


```
public class ViewStructureCompat
```

<br />

*** ** * ** ***

Helper for accessing features in `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 methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/core/view/ViewStructureCompat#setClassName(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html string)` Set the class name of the view, as per `https://developer.android.com/reference/android/view/View.html#getAccessibilityClassName()`. |
| `void` | `https://developer.android.com/reference/androidx/core/view/ViewStructureCompat#setContentDescription(java.lang.CharSequence)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/CharSequence.html charSequence)` Set the content description of the view, as per `https://developer.android.com/reference/android/view/View.html#getContentDescription()`. |
| `void` | `https://developer.android.com/reference/androidx/core/view/ViewStructureCompat#setDimens(int,int,int,int,int,int)( int left, int top, int scrollX, int scrollY, int width, int height )` Set the basic dimensions of this view. |
| `void` | `https://developer.android.com/reference/androidx/core/view/ViewStructureCompat#setText(java.lang.CharSequence)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/CharSequence.html charSequence)` Set the text that is associated with this view. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/ViewStructure.html` | `https://developer.android.com/reference/androidx/core/view/ViewStructureCompat#toViewStructure()()` Provides the `https://developer.android.com/reference/android/view/ViewStructure.html` represented by this object. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/view/ViewStructureCompat` | `https://developer.android.com/reference/androidx/core/view/ViewStructureCompat#toViewStructureCompat(android.view.ViewStructure)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/ViewStructure.html contentCaptureSession)` Provides a backward-compatible wrapper for `https://developer.android.com/reference/android/view/ViewStructure.html`. |

## Public methods

### setClassName

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

```
public void setClassName(@NonNull String string)
```

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

### setContentDescription

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

```
public void setContentDescription(@NonNull CharSequence charSequence)
```

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

### setDimens

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

```
public void setDimens(
    int left,
    int top,
    int scrollX,
    int scrollY,
    int width,
    int height
)
```

Set the basic dimensions of this view.

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

### setText

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

```
public void setText(@NonNull CharSequence charSequence)
```

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.

### toViewStructure

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

```
public @NonNull ViewStructure toViewStructure()
```

Provides the `https://developer.android.com/reference/android/view/ViewStructure.html` represented by this object.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/ViewStructure.html` | platform class object |

| See also |
|---|---|
| `https://developer.android.com/reference/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)

```
public static @NonNull ViewStructureCompat toViewStructureCompat(@NonNull ViewStructure contentCaptureSession)
```

Provides a backward-compatible wrapper for `https://developer.android.com/reference/android/view/ViewStructure.html`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/ViewStructure.html contentCaptureSession` | platform class to wrap |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/view/ViewStructureCompat` | wrapped class |