background

Function

Android
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

colorThe color to set as the background.
Android
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

colorThe color resource to set as the background.
Android
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

colorProviderThe color to set as the background
Android

Deprecated This method has been deprecated in favor of the one that accepts a colorFilter.

fun GlanceModifier.background(
    imageProvider: ImageProvider,
    contentScale: ContentScale = ContentScale.FillBounds
): GlanceModifier

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

Parameters

imageProviderThe content to set as the background
contentScalescaling to apply to the imageProvider.
Android
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

imageProviderThe content to set as the background
contentScalescaling to apply to the imageProvider.
colorFilterOptional color filter to apply to imageProvider, such as tint.
Android
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

imageProviderThe content to set as the background
contentScalescaling to apply to the imageProvider.
colorFilterOptional color filter to apply to imageProvider, such as tint.
alphaOpacity (0f to 1f) to apply to the background image.