background

Function
Android
public 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 The color to set as the background.
Android
public fun GlanceModifier.background(@ColorRes color: 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 The color resource to set as the background.
Android
public 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 The color to set as the background
Android
Deprecated This method has been deprecated in favor of the one that accepts a colorFilter.
public fun GlanceModifier.background(
    imageProvider: ImageProvider,
    contentScale: ContentScale = ContentScale.FillBounds,
): GlanceModifier

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

Parameters

imageProvider The content to set as the background
contentScale scaling to apply to the imageProvider.
Android
public 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 The content to set as the background
contentScale scaling to apply to the imageProvider.
colorFilter Optional color filter to apply to imageProvider, such as tint.
Android
public fun GlanceModifier.background(
    imageProvider: ImageProvider,
    @FloatRange(from = 0.0, to = 1.0) alpha: Float,
    contentScale: ContentScale = ContentScale.FillBounds,
    colorFilter: ColorFilter? = null,
): GlanceModifier

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

Parameters

imageProvider The content to set as the background
contentScale scaling to apply to the imageProvider.
colorFilter Optional color filter to apply to imageProvider, such as tint.
alpha Opacity (0f to 1f) to apply to the background image.