ForegroundCarColorSpan
@CarProtocol
public final class ForegroundCarColorSpan extends CarSpan
| java.lang.Object | |||
| ↳ | android.text.style.CharacterStyle | ||
| ↳ | androidx.car.app.model.CarSpan | ||
| ↳ | androidx.car.app.model.ForegroundCarColorSpan |
A span that changes the color of the text to which the span is attached.
For example, to set a green text color to a span of a string:
SpannableString string = new SpannableString("Text with a foreground color span"); string.setSpan(ForegroundCarColorSpan.create(CarColor.GREEN), 12, 28, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE));
The host may ignore the color specified in the ForegroundCarColorSpan and instead use a default color unless support for ForegroundCarColorSpan is explicitly documented in the API that takes the string. Depending on contrast requirements, capabilities of the vehicle screens, or other factors, the color may also be ignored by the host or overridden by the vehicle system.
| See also | |
|---|---|
CarColor |
|
ForegroundColorSpan |
Summary
Public methods |
|
|---|---|
static @NonNull ForegroundCarColorSpan |
Creates a |
boolean |
|
@NonNull CarColor |
getColor()Returns the |
int |
hashCode() |
@NonNull String |
toString() |
Inherited methods |
||||||
|---|---|---|---|---|---|---|
|
||||||
|
Public methods
create
public static @NonNull ForegroundCarColorSpan create(@NonNull CarColor carColor)
Creates a ForegroundColorSpan from a CarColor.
Custom colors created with createCustom are not supported in text spans unless explicitly documented otherwise in the API that takes the string.
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
if |
java.lang.NullPointerException |
if |