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()
Determines if Android is after 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, 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(android.text.TextPaint textPaint, android.graphics.Typeface typeface, int style)
public static android.graphics.Typeface setTypefaceFromAttrs(java.lang.String familyName, int typefaceIndex, int styleIndex)
public static android.graphics.PorterDuff.Mode parseTintMode(int value, android.graphics.PorterDuff.Mode defaultMode)
public static android.text.Layout.Alignment getTextAlignment(android.content.res.Resources resources, int gravity, java.lang.CharSequence text)
gravity
- The gravity to convert to absolute valuespublic static boolean isVersionAfterJellyBeanMR1()
public static android.text.StaticLayout createStaticTextLayout(java.lang.CharSequence text, android.text.TextPaint paint, int maxTextWidth, 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(android.graphics.PointF origin, android.graphics.RectF base, 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(android.text.Layout layout, 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(android.text.Layout textLayout)
textLayout
- The text layoutpublic static boolean containsInset(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.