public class PromptUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static float |
calculateMaxTextWidth(android.text.Layout textLayout)
Calculates the maximum width line in a text layout.
|
static float |
calculateMaxWidth(float maxTextWidth,
android.graphics.Rect clipBounds,
int parentWidth,
float textPadding)
Calculates the maximum width that the prompt can be.
|
static boolean |
containsInset(android.graphics.Rect bounds,
int inset,
int x,
int y)
Determines if a point is within a rectangle that has been inset.
|
static android.text.StaticLayout |
createStaticTextLayout(java.lang.CharSequence text,
android.text.TextPaint paint,
int maxTextWidth,
android.text.Layout.Alignment textAlignment,
float alphaModifier)
Creates a static text layout.
|
static android.text.Layout.Alignment |
getTextAlignment(android.content.res.Resources resources,
int gravity,
java.lang.CharSequence text)
Gets the absolute text alignment value based on the supplied gravity and the activities
layout direction.
|
static boolean |
isPointInCircle(float x,
float y,
android.graphics.PointF circleCentre,
float radius)
Determines if a point is in the centre of a circle with a radius from the point.
|
static boolean |
isRtlText(android.text.Layout layout,
android.content.res.Resources resources)
Determines if the text in the supplied layout is displayed right to left.
|
static boolean |
isVersionAfterJellyBeanMR1()
Deprecated.
use Build directly:
Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 |
static android.graphics.PorterDuff.Mode |
parseTintMode(int value,
android.graphics.PorterDuff.Mode defaultMode)
Based on parseTintMode in android appcompat v7 DrawableUtils, Copyright (C) 2014 The
Android Open Source Project.
|
static void |
scale(android.graphics.PointF origin,
android.graphics.RectF base,
android.graphics.RectF out,
float scale,
boolean even)
Scales a rectangle.
|
static void |
setTypeface(android.text.TextPaint textPaint,
android.graphics.Typeface typeface,
int style)
Based on setTypeface in android TextView, Copyright (C) 2006 The Android Open Source
Project.
|
static android.graphics.Typeface |
setTypefaceFromAttrs(java.lang.String familyName,
int typefaceIndex,
int styleIndex)
Based on setTypefaceFromAttrs in android TextView, Copyright (C) 2006 The Android Open
Source Project.
|
public static boolean isPointInCircle(float x, float y, @NonNull android.graphics.PointF circleCentre, float radius)
x
- The x position in the view.y
- The y position in the view.circleCentre
- The circle centre positionradius
- The radius of the circle.public static void setTypeface(@NonNull android.text.TextPaint textPaint, @Nullable android.graphics.Typeface typeface, int style)
@NonNull public static android.graphics.Typeface setTypefaceFromAttrs(@Nullable java.lang.String familyName, int typefaceIndex, int styleIndex)
@Nullable public static android.graphics.PorterDuff.Mode parseTintMode(int value, @Nullable android.graphics.PorterDuff.Mode defaultMode)
@NonNull public static android.text.Layout.Alignment getTextAlignment(@NonNull android.content.res.Resources resources, int gravity, @Nullable java.lang.CharSequence text)
gravity
- The gravity to convert to absolute values@NonNull public static android.text.StaticLayout createStaticTextLayout(@NonNull java.lang.CharSequence text, @NonNull android.text.TextPaint paint, int maxTextWidth, @NonNull android.text.Layout.Alignment textAlignment, float alphaModifier)
StaticLayout.Builder
if
available.text
- The text to be laid out, optionally with spanspaint
- The base paint used for layoutmaxTextWidth
- The width in pixelstextAlignment
- Alignment for the resulting StaticLayout
alphaModifier
- The modification to apply to the alpha value between 0 and 1.StaticLayout
objectpublic static void scale(@NonNull android.graphics.PointF origin, @NonNull android.graphics.RectF base, @NonNull android.graphics.RectF out, float scale, boolean even)
origin
- The point to scale from.base
- The rectangle at scale 1.0.out
- The rectangle to put the scaled size in.scale
- The amount to scale the rectangle by.even
- Should the rectangle be scaled evenly in both directions.public static boolean isRtlText(@Nullable android.text.Layout layout, @NonNull android.content.res.Resources resources)
layout
- The layout to check.public static float calculateMaxWidth(float maxTextWidth, @Nullable android.graphics.Rect clipBounds, int parentWidth, float textPadding)
public static float calculateMaxTextWidth(@Nullable android.text.Layout textLayout)
textLayout
- The text layoutpublic static boolean containsInset(@NonNull android.graphics.Rect bounds, int inset, int x, int y)
bounds
- The rectangle bounds.inset
- The amount that the rectangle is inset by.x
- The point x coordinate.y
- The point y coordinate.@Deprecated public static boolean isVersionAfterJellyBeanMR1()
Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1