ForegroundCarColorSpan
public
class
ForegroundCarColorSpan
extends CharacterStyle
java.lang.Object | ||
↳ | android.text.style.CharacterStyle | |
↳ | com.google.android.libraries.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. The host may use a default color if the color in the span does not
pass the contrast requirements.
See also:
Summary
Public methods | |
---|---|
static
ForegroundCarColorSpan
|
create(CarColor carColor)
Creates a |
boolean
|
equals(Object other)
|
int
|
hashCode()
|
String
|
toString()
|
void
|
updateDrawState(TextPaint paint)
|
Inherited methods | |
---|---|
Public methods
create
public static ForegroundCarColorSpan create (CarColor carColor)
Creates a ForegroundColorSpan
from a CarColor
.
Custom colors created with CarColor.createCustom(int, int)
are not supported in text spans.
Parameters | |
---|---|
carColor |
CarColor |
Returns | |
---|---|
ForegroundCarColorSpan |
Throws | |
---|---|
IllegalArgumentException |
if carColor contains a custom color. |
NullPointerException |
if carColor is null .
|
hashCode
public int hashCode ()
Returns | |
---|---|
int |