# Preview

Artifact: [androidx.wear.tiles:tiles-tooling-preview](https://developer.android.com/jetpack/androidx/releases/wear-tiles) [View Source](https://cs.android.com/search?q=file:androidx/wear/tiles/tooling/preview/Preview.kt+class:androidx.wear.tiles.tooling.preview.Preview) Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.3.0)

*** ** * ** ***


```
@Retention(value = AnnotationRetention.BINARY)
@Target(allowedTargets = [AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.FUNCTION])
@Repeatable
@MustBeDocumented
public annotation Preview
```

<br />

*** ** * ** ***

The annotation that marks Tile preview components that should have a visual preview in the Android Studio preview panel. Tile preview components are methods that take an optional `https://developer.android.com/reference/android/content/Context.html` parameter and return a `https://developer.android.com/reference/androidx/wear/tiles/tooling/preview/TilePreviewData`. Methods annotated with `https://developer.android.com/reference/androidx/wear/tiles/tooling/preview/Preview` must be top level declarations or in a top level class with a default constructor.

For example:

```
@Preview
fun myTilePreview(): TilePreviewData {
    return TilePreviewData { request -> myTile(request) }
}
```

or:

```
@Preview
fun myTilePreview(context: Context): TilePreviewData {
    return TilePreviewData { request -> myTile(request, context) }
}
```

Because of the way previews are rendered within Android Studio, they are lightweight and don't require the whole Android framework to render them. However, this comes with the following limitations:

- No network access

- No file access

- Some `https://developer.android.com/reference/android/content/Context.html` APIs may not be fully available, such as launching activities or retrieving services

For more information, see https://developer.android.com/jetpack/compose/tooling/previews#preview-limitations

The schema renderer version used to render the preview will match the version of the tiles library.

The annotation contains a number of parameters that allow to define the way the Tile will be rendered within the preview. The passed parameters are only read by Studio when rendering the preview.

## Summary

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/wear/tiles/tooling/preview/Preview#getDevice()()` Device identifier indicating the device to use in the preview. |
| `final float` | `https://developer.android.com/reference/androidx/wear/tiles/tooling/preview/Preview#getFontScale()()` User preference for the linear scaling factor for fonts, relative to the base density scaling. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/wear/tiles/tooling/preview/Preview#getGroup()()` Group name for this @`https://developer.android.com/reference/androidx/wear/tiles/tooling/preview/Preview`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/wear/tiles/tooling/preview/Preview#getLocale()()` Current user preference for the locale, corresponding to [locale](https://d.android.com/guide/topics/resources/providing-resources.html#LocaleQualifier) resource qualifier. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/wear/tiles/tooling/preview/Preview#getName()()` Display name of this preview allowing to identify it in the panel. |

## Public methods

### getDevice

```
public final @NonNull String getDevice()
```

Device identifier indicating the device to use in the preview. For example "id:wearos_small_round".See the available devices in `https://developer.android.com/reference/androidx/wear/tooling/preview/devices/WearDevices`.

### getFontScale

```
public final float getFontScale()
```

User preference for the linear scaling factor for fonts, relative to the base density scaling.

### getGroup

```
public final @NonNull String getGroup()
```

Group name for this @`https://developer.android.com/reference/androidx/wear/tiles/tooling/preview/Preview`. This allows grouping them in the UI and displaying only one or more of them.

### getLocale

```
public final @NonNull String getLocale()
```

Current user preference for the locale, corresponding to [locale](https://d.android.com/guide/topics/resources/providing-resources.html#LocaleQualifier) resource qualifier. By default, the `default` folder will be used.

### getName

```
public final @NonNull String getName()
```

Display name of this preview allowing to identify it in the panel.