{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

TextSelectionColors

public final class TextSelectionColors


Represents the colors used for text selection by text and text field components.

See LocalTextSelectionColors to provide new values for this throughout the hierarchy.

Summary

Public constructors

TextSelectionColors(
    @NonNull Color handleColor,
    @NonNull Color backgroundColor
)

Public methods

boolean
equals(Object other)
final @NonNull Color

the color used to draw the background behind the selected region.

final @NonNull Color

the color used for the selection handles on either side of the selection region.

int
@NonNull String

Public constructors

TextSelectionColors

public TextSelectionColors(
    @NonNull Color handleColor,
    @NonNull Color backgroundColor
)

Public methods

equals

public boolean equals(Object other)

getBackgroundColor

public final @NonNull Color getBackgroundColor()

the color used to draw the background behind the selected region. This color should have alpha applied to keep the text legible - this alpha is typically 0.4f (40%) but this may need to be reduced in order to meet contrast requirements depending on the color used for text, selection background, and the background behind the selection background.

getHandleColor

public final @NonNull Color getHandleColor()

the color used for the selection handles on either side of the selection region.

hashCode

public int hashCode()

toString

public @NonNull String toString()