/** * Sets the text color for the layout. * * @param color The text color for the layout * @return This {@link TextLayoutBuilder} instance */ public TextLayoutBuilder setTextColor(@ColorInt int color) { mParams.createNewPaintIfNeeded(); mParams.color = null; mParams.paint.setColor(color); mSavedLayout = null; return this; }
/** * Sets the link color for the text in the layout. * * @param linkColor The link color * @return This {@link TextLayoutBuilder} instance */ public TextLayoutBuilder setLinkColor(@ColorInt int linkColor) { if (mParams.paint.linkColor != linkColor) { mParams.createNewPaintIfNeeded(); mParams.paint.linkColor = linkColor; mSavedLayout = null; } return this; }
/** * Sets the text color for the layout. * * @param colorStateList The text color state list for the layout * @return This {@link TextLayoutBuilder} instance */ public TextLayoutBuilder setTextColor(ColorStateList colorStateList) { mParams.createNewPaintIfNeeded(); mParams.color = colorStateList; mParams.paint.setColor(mParams.color != null ? mParams.color.getDefaultColor() : Color.BLACK); mSavedLayout = null; return this; }
/** * Sets the shadow layer for the layout. * * @param radius The radius of the blur for shadow * @param dx The horizontal translation of the origin * @param dy The vertical translation of the origin * @param color The shadow color * @return This {@link TextLayoutBuilder} instance */ public TextLayoutBuilder setShadowLayer(float radius, float dx, float dy, @ColorInt int color) { mParams.createNewPaintIfNeeded(); mParams.mShadowRadius = radius; mParams.mShadowDx = dx; mParams.mShadowDy = dy; mParams.mShadowColor = color; mParams.paint.setShadowLayer(radius, dx, dy, color); mSavedLayout = null; return this; }
/** * Sets text letter-spacing in em units. Typical values for slight expansion will be around 0.05. * Negative values tighten text. * * @param letterSpacing A text letter-space value in ems. * @see #getLetterSpacing() */ @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) public TextLayoutBuilder setLetterSpacing(float letterSpacing) { if (getLetterSpacing() != letterSpacing) { mParams.createNewPaintIfNeeded(); mParams.paint.setLetterSpacing(letterSpacing); mSavedLayout = null; } return this; }
/** * Updates the text colors based on the drawable state. * * @param drawableState The current drawable state of the View holding this layout * @return This {@link TextLayoutBuilder} instance */ public TextLayoutBuilder setDrawableState(int[] drawableState) { mParams.createNewPaintIfNeeded(); mParams.paint.drawableState = drawableState; if (mParams.color != null && mParams.color.isStateful()) { int color = mParams.color.getColorForState(drawableState, 0); mParams.paint.setColor(color); mSavedLayout = null; } return this; }
/** * Sets the density of this layout. This should typically be set to your current display's density * * @param density The density desired * @return This {@link TextLayoutBuilder} */ public TextLayoutBuilder setDensity(float density) { if (mParams.paint.density != density) { mParams.createNewPaintIfNeeded(); mParams.paint.density = density; mSavedLayout = null; } return this; }
/** * Sets the text size for the layout. * * @param size The text size in pixels * @return This {@link TextLayoutBuilder} instance */ public TextLayoutBuilder setTextSize(int size) { if (mParams.paint.getTextSize() != size) { mParams.createNewPaintIfNeeded(); mParams.paint.setTextSize(size); mSavedLayout = null; } return this; }
/** * Sets the typeface used by this TextLayoutBuilder. * * @param typeface The typeface for this TextLayoutBuilder * @return This {@link TextLayoutBuilder} instance */ public TextLayoutBuilder setTypeface(Typeface typeface) { if (mParams.paint.getTypeface() != typeface) { mParams.createNewPaintIfNeeded(); mParams.paint.setTypeface(typeface); mSavedLayout = null; } return this; }