TopAppBarColors

Class

Common
@ExperimentalMaterial3Api
class TopAppBarColors(
    val containerColor: Color,
    val scrolledContainerColor: Color,
    val navigationIconContentColor: Color,
    val titleContentColor: Color,
    val actionIconContentColor: Color,
    val subtitleContentColor: Color,
)

Represents the colors used by a top app bar in different states. This implementation animates the container color according to the top app bar scroll state. It does not animate the leading, headline, or trailing colors.

Parameters

containerColorthe color used for the background of this TopAppBar. Use Color.Transparent to have no color.
scrolledContainerColorthe container color when content is scrolled behind it
navigationIconContentColorthe content color used for the navigation icon
titleContentColorthe content color used for the title
actionIconContentColorthe content color used for actions
subtitleContentColorthe content color used for a subtitle

Secondary Constructors

constructor(
    containerColor: Color,
    scrolledContainerColor: Color,
    navigationIconContentColor: Color,
    titleContentColor: Color,
    actionIconContentColor: Color,
) : this(
    containerColor = containerColor,
    scrolledContainerColor = scrolledContainerColor,
    navigationIconContentColor = navigationIconContentColor,
    titleContentColor = titleContentColor,
    actionIconContentColor = actionIconContentColor,
    subtitleContentColor = titleContentColor,
)

Functions

fun copy(
        containerColor: Color = this.containerColor,
        scrolledContainerColor: Color = this.scrolledContainerColor,
        navigationIconContentColor: Color = this.navigationIconContentColor,
        titleContentColor: Color = this.titleContentColor,
        actionIconContentColor: Color = this.actionIconContentColor,
        subtitleContentColor: Color = this.subtitleContentColor,
    ) =
        TopAppBarColors(
            containerColor.takeOrElse { this.containerColor },
            scrolledContainerColor.takeOrElse { this.scrolledContainerColor },
            navigationIconContentColor.takeOrElse { this.navigationIconContentColor },
            titleContentColor.takeOrElse { this.titleContentColor },
            actionIconContentColor.takeOrElse { this.actionIconContentColor },
            subtitleContentColor.takeOrElse { this.subtitleContentColor },
        )

Returns a copy of this TopAppBarColors, optionally overriding some of the values. This uses the Color.Unspecified to mean “use the value from the source”