androidx.glance

Interfaces

GlanceId

Opaque object used to describe a glance view.

GlanceModifier

An ordered, immutable, collection of modifier element for the Glance library.

GlanceModifier.Element

A single element contained within a GlanceModifier chain.

ImageProvider

Interface representing an Image source which can be used with a Glance Image element.

Classes

ButtonColors

Represents the colors used to style a button, prefer this to using the modifier.

ColorFilter

Effects used to modify the color of an image.

CombinedGlanceModifier

A node in a GlanceModifier chain.

Objects

ButtonDefaults

Contains the default values used by Button.

GlanceModifier.Companion

The companion object Modifier is the empty, default, or starter GlanceModifier that contains no elements.

GlanceTheme

Object that provides access to the current theme.

Annotations

ExperimentalGlanceApi
GlanceComposable

An annotation that can be used to mark a composable function as being expected to be use in a composable function that is also marked or inferred to be marked as a GlanceComposable.

Enums

Visibility

Value of the visibility field for a node in the composition tree.

Composables

Button

Adds a button view to the glance view.

GlanceTheme

A top level theme for Glance code.

Image

A composable which lays out and draws the image specified in provider.

currentState

Retrieves the current customizable store for view specific state data as defined by GlanceStateDefinition in the surface implementation.

Top-level functions summary

ImageProvider

Image resource from a bitmap.

ImageProvider
@RequiresApi(value = 23)
ImageProvider(icon: Icon)

Image resource from an icon.

ImageProvider

Image resource from an Android Drawable resource.

Extension functions summary

GlanceModifier

Apply a background color to the element this modifier is attached to.

GlanceModifier

Apply a background color to the element this modifier is attached to.

GlanceModifier

Apply a background color to the element this modifier is attached to.

GlanceModifier
GlanceModifier.background(
    imageProvider: ImageProvider,
    contentScale: ContentScale,
    colorFilter: ColorFilter?
)

Apply a background image to the element this modifier is attached to.

GlanceModifier
GlanceModifier.background(
    imageProvider: ImageProvider,
    alpha: @FloatRange(from = 0.0, to = 1.0) Float,
    contentScale: ContentScale,
    colorFilter: ColorFilter?
)

Apply a background image to the element this modifier is attached to.

GlanceModifier

Change the visibility of the current node.

Top-level properties summary

ProvidableCompositionLocal<Context>

Context of application when generating the glance view.

ProvidableCompositionLocal<GlanceId>

Unique Id for the glance view being generated by the current composition.

ProvidableCompositionLocal<DpSize>

Size of the glance view being generated.

ProvidableCompositionLocal<Any?>

Local view state, defined in surface implementation.

Top-level functions

ImageProvider

fun ImageProvider(bitmap: Bitmap): ImageProvider

Image resource from a bitmap.

Parameters
bitmap: Bitmap

The bitmap to be displayed.

ImageProvider

@RequiresApi(value = 23)
fun ImageProvider(icon: Icon): ImageProvider

Image resource from an icon.

Parameters
icon: Icon

The icon to be displayed.

ImageProvider

fun ImageProvider(resId: @DrawableRes Int): ImageProvider

Image resource from an Android Drawable resource.

Parameters
resId: @DrawableRes Int

The resource ID of the Drawable resource to be used.

Extension functions

GlanceModifier.background

fun GlanceModifier.background(color: Color): GlanceModifier

Apply a background color to the element this modifier is attached to. This will cause the element to paint the specified Color as its background, which will fill the bounds of the element.

Parameters
color: Color

The color to set as the background.

GlanceModifier.background

fun GlanceModifier.background(color: @ColorRes Int): GlanceModifier

Apply a background color to the element this modifier is attached to. This will cause the element to paint the specified color resource as its background, which will fill the bounds of the element.

Parameters
color: @ColorRes Int

The color resource to set as the background.

GlanceModifier.background

fun GlanceModifier.background(colorProvider: ColorProvider): GlanceModifier

Apply a background color to the element this modifier is attached to. This will cause the element to paint the specified ColorProvider as its background, which will fill the bounds of the element.

Parameters
colorProvider: ColorProvider

The color to set as the background

GlanceModifier.background

fun GlanceModifier.background(
    imageProvider: ImageProvider,
    contentScale: ContentScale = ContentScale.FillBounds,
    colorFilter: ColorFilter? = null
): GlanceModifier

Apply a background image to the element this modifier is attached to.

Parameters
imageProvider: ImageProvider

The content to set as the background

contentScale: ContentScale = ContentScale.FillBounds

scaling to apply to the imageProvider.

colorFilter: ColorFilter? = null

Optional color filter to apply to imageProvider, such as tint.

GlanceModifier.background

fun GlanceModifier.background(
    imageProvider: ImageProvider,
    alpha: @FloatRange(from = 0.0, to = 1.0) Float,
    contentScale: ContentScale = ContentScale.FillBounds,
    colorFilter: ColorFilter? = null
): GlanceModifier

Apply a background image to the element this modifier is attached to.

Parameters
imageProvider: ImageProvider

The content to set as the background

alpha: @FloatRange(from = 0.0, to = 1.0) Float

Opacity (0f to 1f) to apply to the background image.

contentScale: ContentScale = ContentScale.FillBounds

scaling to apply to the imageProvider.

colorFilter: ColorFilter? = null

Optional color filter to apply to imageProvider, such as tint.

GlanceModifier.visibility

fun GlanceModifier.visibility(visibility: Visibility): GlanceModifier

Change the visibility of the current node.

Parameters
visibility: Visibility

New visibility of the node.

Top-level properties

LocalContext

val LocalContextProvidableCompositionLocal<Context>

Context of application when generating the glance view.

LocalGlanceId

val LocalGlanceIdProvidableCompositionLocal<GlanceId>

Unique Id for the glance view being generated by the current composition.

LocalSize

val LocalSizeProvidableCompositionLocal<DpSize>

Size of the glance view being generated.

The glance view will have at least that much space to be displayed. The exact meaning may changed depending on the surface and how it is configured.

LocalState

val LocalStateProvidableCompositionLocal<Any?>

Local view state, defined in surface implementation. A customizable store for view specific state data.