# MaterialScopeKt

Added in 1.3.0

*** ** * ** ***


```
public final class MaterialScopeKt
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement` | `https://developer.android.com/reference/androidx/wear/protolayout/material3/MaterialScopeKt#materialScope(android.content.Context,androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters,kotlin.Boolean,androidx.wear.protolayout.material3.ColorScheme,kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/DeviceParametersBuilders.DeviceParameters deviceConfiguration, boolean allowDynamicTheme, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/material3/ColorScheme defaultColorScheme, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/material3/MaterialScope, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement> layout )` Creates a top-level receiver scope `https://developer.android.com/reference/androidx/wear/protolayout/material3/MaterialScope` that calls the given `https://developer.android.com/reference/androidx/wear/protolayout/material3/package-summary#materialScope(android.content.Context,androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters,kotlin.Boolean,androidx.wear.protolayout.material3.ColorScheme,kotlin.Function1)` to support for opinionated defaults and building Material3 components and layout, with default dynamic theme colors defined in `https://developer.android.com/reference/androidx/wear/protolayout/material3/package-summary#dynamicColorScheme(android.content.Context,androidx.wear.protolayout.material3.ColorScheme)`. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement` | `https://developer.android.com/reference/androidx/wear/protolayout/material3/MaterialScopeKt#materialScopeWithResources(android.content.Context,androidx.wear.protolayout.ProtoLayoutScope,androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters,kotlin.Boolean,androidx.wear.protolayout.material3.ColorScheme,kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/ProtoLayoutScope protoLayoutScope, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/DeviceParametersBuilders.DeviceParameters deviceConfiguration, boolean allowDynamicTheme, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/material3/ColorScheme defaultColorScheme, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/material3/MaterialScope, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement> layout )` Creates a top-level receiver scope `https://developer.android.com/reference/androidx/wear/protolayout/material3/MaterialScope` that calls the given `https://developer.android.com/reference/androidx/wear/protolayout/material3/package-summary#materialScopeWithResources(android.content.Context,androidx.wear.protolayout.ProtoLayoutScope,androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters,kotlin.Boolean,androidx.wear.protolayout.material3.ColorScheme,kotlin.Function1)` to support for opinionated defaults and building Material3 components and layout, with default dynamic theme colors defined in `https://developer.android.com/reference/androidx/wear/protolayout/material3/package-summary#dynamicColorScheme(android.content.Context,androidx.wear.protolayout.material3.ColorScheme)` and automatic resource registration for `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Image` elements created with `https://developer.android.com/reference/androidx/wear/protolayout/ProtoLayoutScope`. |

## Public methods

### materialScope

Artifact: [androidx.wear.protolayout:protolayout-material3](https://developer.android.com/jetpack/androidx/releases/wear-protolayout) [View Source](https://cs.android.com/search?q=file:androidx/wear/protolayout/material3/MaterialScope.kt+function:materialScope)

```
public static final @NonNull LayoutElementBuilders.LayoutElement materialScope(
    @NonNull Context context,
    @NonNull DeviceParametersBuilders.DeviceParameters deviceConfiguration,
    boolean allowDynamicTheme,
    @NonNull ColorScheme defaultColorScheme,
    @NonNull Function1<@NonNull MaterialScope, @NonNull LayoutElementBuilders.LayoutElement> layout
)
```

Creates a top-level receiver scope `https://developer.android.com/reference/androidx/wear/protolayout/material3/MaterialScope` that calls the given `https://developer.android.com/reference/androidx/wear/protolayout/material3/package-summary#materialScope(android.content.Context,androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters,kotlin.Boolean,androidx.wear.protolayout.material3.ColorScheme,kotlin.Function1)` to support for opinionated defaults and building Material3 components and layout, with default dynamic theme colors defined in `https://developer.android.com/reference/androidx/wear/protolayout/material3/package-summary#dynamicColorScheme(android.content.Context,androidx.wear.protolayout.material3.ColorScheme)`.

The colors of elements in this receiver scope will automatically follow colors from the system theme, including whenever user changes the theme. If dynamic color scheme is switched off by user or unavailable on device, defaults to static, default `https://developer.android.com/reference/androidx/wear/protolayout/material3/ColorScheme`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context` | The Android Context for the Tile service |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/DeviceParametersBuilders.DeviceParameters deviceConfiguration` | The device parameters for where the components will be rendered |
| `boolean allowDynamicTheme` | Whether dynamic colors theme should be used on components, meaning that colors will follow the system theme if enabled on the device. If not set, defaults to using the system theme |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/material3/ColorScheme defaultColorScheme` | Color Scheme with static colors. The color theme to be used, when `allowDynamicTheme` is false, or when dynamic theming is disabled by the system or user. If not set, defaults to default theme. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/material3/MaterialScope, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement> layout` | Scoped slot for the content of layout to be displayed |

### materialScopeWithResources

Artifact: [androidx.wear.protolayout:protolayout-material3](https://developer.android.com/jetpack/androidx/releases/wear-protolayout) [View Source](https://cs.android.com/search?q=file:androidx/wear/protolayout/material3/MaterialScope.kt+function:materialScopeWithResources)

```
public static final @NonNull LayoutElementBuilders.LayoutElement materialScopeWithResources(
    @NonNull Context context,
    @NonNull ProtoLayoutScope protoLayoutScope,
    @NonNull DeviceParametersBuilders.DeviceParameters deviceConfiguration,
    boolean allowDynamicTheme,
    @NonNull ColorScheme defaultColorScheme,
    @NonNull Function1<@NonNull MaterialScope, @NonNull LayoutElementBuilders.LayoutElement> layout
)
```

Creates a top-level receiver scope `https://developer.android.com/reference/androidx/wear/protolayout/material3/MaterialScope` that calls the given `https://developer.android.com/reference/androidx/wear/protolayout/material3/package-summary#materialScopeWithResources(android.content.Context,androidx.wear.protolayout.ProtoLayoutScope,androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters,kotlin.Boolean,androidx.wear.protolayout.material3.ColorScheme,kotlin.Function1)` to support for opinionated defaults and building Material3 components and layout, with default dynamic theme colors defined in `https://developer.android.com/reference/androidx/wear/protolayout/material3/package-summary#dynamicColorScheme(android.content.Context,androidx.wear.protolayout.material3.ColorScheme)` and automatic resource registration for `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Image` elements created with `https://developer.android.com/reference/androidx/wear/protolayout/ProtoLayoutScope`.

The colors of elements in this receiver scope will automatically follow colors from the system theme, including whenever user changes the theme. If dynamic color scheme is switched off by user or unavailable on device, defaults to static, default `https://developer.android.com/reference/androidx/wear/protolayout/material3/ColorScheme`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context` | The Android Context for the Tile service |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/ProtoLayoutScope protoLayoutScope` | The `https://developer.android.com/reference/androidx/wear/protolayout/ProtoLayoutScope` for the Tile service, which should be obtained via `androidx.wear.tiles.RequestBuilders#TileRequest.getScope` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/DeviceParametersBuilders.DeviceParameters deviceConfiguration` | The device parameters for where the components will be rendered |
| `boolean allowDynamicTheme` | Whether dynamic colors theme should be used on components, meaning that colors will follow the system theme if enabled on the device. If not set, defaults to using the system theme |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/material3/ColorScheme defaultColorScheme` | Color Scheme with static colors. The color theme to be used, when `allowDynamicTheme` is false, or when dynamic theming is disabled by the system or user. If not set, defaults to default theme. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/material3/MaterialScope, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement> layout` | Scoped slot for the content of layout to be displayed |