TextLayoutBuilder { public TextLayoutBuilder setTextColor(@ColorInt int color) { mParams.createNewPaintIfNeeded(); mParams.color = null; mParams.paint.setColor(color); mSavedLayout = null; return this; }  TextLayoutBuilder setWidth(@Px int width); TextLayoutBuilder setWidth(@Px int width, @MeasureMode int measureMode); CharSequence getText(); TextLayoutBuilder setText(CharSequence text); float getTextSize(); TextLayoutBuilder setTextSize(int size); @ColorInt int getTextColor(); TextLayoutBuilder setTextColor(@ColorInt int color); TextLayoutBuilder setTextColor(ColorStateList colorStateList); @ColorInt int getLinkColor(); TextLayoutBuilder setLinkColor(@ColorInt int linkColor); float getTextSpacingExtra(); TextLayoutBuilder setTextSpacingExtra(float spacingExtra); float getTextSpacingMultiplier(); TextLayoutBuilder setTextSpacingMultiplier(float spacingMultiplier); float getLineHeight(); TextLayoutBuilder setLineHeight(float lineHeight); @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) float getLetterSpacing(); @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) TextLayoutBuilder setLetterSpacing(float letterSpacing); boolean getIncludeFontPadding(); TextLayoutBuilder setIncludeFontPadding(boolean shouldInclude); Alignment getAlignment(); TextLayoutBuilder setAlignment(Alignment alignment); TextDirectionHeuristicCompat getTextDirection(); TextLayoutBuilder setTextDirection(TextDirectionHeuristicCompat textDirection); TextLayoutBuilder setShadowLayer(float radius, float dx, float dy, @ColorInt int color); TextLayoutBuilder setTextStyle(int style); Typeface getTypeface(); TextLayoutBuilder setTypeface(Typeface typeface); int[] getDrawableState(); TextLayoutBuilder setDrawableState(int[] drawableState); TextUtils.TruncateAt getEllipsize(); TextLayoutBuilder setEllipsize(TextUtils.TruncateAt ellipsize); @RequiresApi(api = 28) TextLayoutBuilder setUseLineSpacingFromFallbacks(boolean status); boolean getUseLineSpacingFromFallbacks(); boolean getSingleLine(); TextLayoutBuilder setSingleLine(boolean singleLine); int getMaxLines(); TextLayoutBuilder setMaxLines(int maxLines); int getBreakStrategy(); TextLayoutBuilder setBreakStrategy(int breakStrategy); int getHyphenationFrequency(); TextLayoutBuilder setHyphenationFrequency(int hyphenationFrequency); int[] getLeftIndents(); int[] getRightIndents(); TextLayoutBuilder setIndents(int[] leftIndents, int[] rightIndents); boolean getShouldCacheLayout(); TextLayoutBuilder setShouldCacheLayout(boolean shouldCacheLayout); boolean getShouldWarmText(); TextLayoutBuilder setShouldWarmText(boolean shouldWarmText); GlyphWarmer getGlyphWarmer(); TextLayoutBuilder setGlyphWarmer(GlyphWarmer glyphWarmer); int getMinEms(); TextLayoutBuilder setMinEms(int minEms); @Px int getMinWidth(); TextLayoutBuilder setMinWidth(@Px int minWidth); int getMaxEms(); TextLayoutBuilder setMaxEms(int maxEms); @Px int getMaxWidth(); TextLayoutBuilder setMaxWidth(@Px int maxWidth); float getDensity(); TextLayoutBuilder setDensity(float density); @RequiresApi(api = Build.VERSION_CODES.O) int getJustificationMode(); @RequiresApi(api = Build.VERSION_CODES.O) TextLayoutBuilder setJustificationMode(int justificationMode); TextLayoutBuilder setShouldLayoutZeroLengthText(boolean shouldLayoutZeroLengthText); @Nullable Layout build(); static final int MEASURE_MODE_UNSPECIFIED; static final int MEASURE_MODE_EXACTLY; static final int MEASURE_MODE_AT_MOST; static final int DEFAULT_MAX_LINES; }
@Test public void testSetTextColor() { mLayout = mBuilder.setTextColor(0xFFFF0000).build(); assertEquals(mBuilder.getTextColor(), 0xFFFF0000); assertEquals(mLayout.getPaint().getColor(), 0xFFFF0000); }