Modifier and Type | Field and Description |
---|---|
int |
assetCookie
Additional information about where the value came from; only
set for strings.
|
int |
changingConfigurations
If Value came from a resource, these are the configurations for which
its contents can change.
|
static int |
COMPLEX_MANTISSA_MASK
Complex data: mask to extract mantissa information (after shifting by
COMPLEX_MANTISSA_SHIFT ). |
static int |
COMPLEX_MANTISSA_SHIFT
Complex data: bit location of mantissa information.
|
static int |
COMPLEX_RADIX_0p23
Complex data: the mantissa magnitude is 0 bits -- i.e, 0x0.nnnnnn
|
static int |
COMPLEX_RADIX_16p7
Complex data: the mantissa magnitude is 16 bits -- i.e, 0xnnnn.nn
|
static int |
COMPLEX_RADIX_23p0
Complex data: the mantissa is an integral number -- i.e., 0xnnnnnn.0
|
static int |
COMPLEX_RADIX_8p15
Complex data: the mantissa magnitude is 8 bits -- i.e, 0xnn.nnnn
|
static int |
COMPLEX_RADIX_MASK
Complex data: mask to extract radix information (after shifting by
COMPLEX_RADIX_SHIFT ). |
static int |
COMPLEX_RADIX_SHIFT
Complex data: where the radix information is, telling where the decimal
place appears in the mantissa.
|
static int |
COMPLEX_UNIT_DIP
TYPE_DIMENSION complex unit: Value is Device Independent
Pixels. |
static int |
COMPLEX_UNIT_FRACTION
TYPE_FRACTION complex unit: A basic fraction of the overall
size. |
static int |
COMPLEX_UNIT_FRACTION_PARENT
TYPE_FRACTION complex unit: A fraction of the parent size. |
static int |
COMPLEX_UNIT_IN
TYPE_DIMENSION complex unit: Value is in inches. |
static int |
COMPLEX_UNIT_MASK
Complex data: mask to extract unit information (after shifting by
COMPLEX_UNIT_SHIFT ). |
static int |
COMPLEX_UNIT_MM
TYPE_DIMENSION complex unit: Value is in millimeters. |
static int |
COMPLEX_UNIT_PT
TYPE_DIMENSION complex unit: Value is in points. |
static int |
COMPLEX_UNIT_PX
TYPE_DIMENSION complex unit: Value is raw pixels. |
static int |
COMPLEX_UNIT_SHIFT
Complex data: bit location of unit information.
|
static int |
COMPLEX_UNIT_SP
TYPE_DIMENSION complex unit: Value is a scaled pixel. |
int |
data
Basic data in the value, interpreted according to
type |
int |
density
If the Value came from a resource, this holds the corresponding pixel density.
|
static int |
DENSITY_DEFAULT
If
density is equal to this value, then the density should be
treated as the system's default density value: DisplayMetrics.DENSITY_DEFAULT . |
static int |
DENSITY_NONE
If
density is equal to this value, then there is no density
associated with the resource and it should not be scaled. |
int |
resourceId
If Value came from a resource, this holds the corresponding resource id.
|
CharSequence |
string
If the value holds a string, this is it.
|
int |
type
The type held by this value, as defined by the constants here.
|
static int |
TYPE_ATTRIBUTE
The data field holds an attribute resource
identifier (referencing an attribute in the current theme
style, not a resource entry).
|
static int |
TYPE_DIMENSION
The data field holds a complex number encoding a
dimension value.
|
static int |
TYPE_FIRST_COLOR_INT
Identifies the start of integer values that were specified as
color constants (starting with '#').
|
static int |
TYPE_FIRST_INT
Identifies the start of plain integer values.
|
static int |
TYPE_FLOAT
The data field holds an IEEE 754 floating point number.
|
static int |
TYPE_FRACTION
The data field holds a complex number encoding a fraction
of a container.
|
static int |
TYPE_INT_BOOLEAN
The data field holds 0 or 1 that was originally
specified as "false" or "true".
|
static int |
TYPE_INT_COLOR_ARGB4
The data field holds a color that was originally
specified as #argb.
|
static int |
TYPE_INT_COLOR_ARGB8
The data field holds a color that was originally
specified as #aarrggbb.
|
static int |
TYPE_INT_COLOR_RGB4
The data field holds a color that was originally
specified as #rgb.
|
static int |
TYPE_INT_COLOR_RGB8
The data field holds a color that was originally
specified as #rrggbb.
|
static int |
TYPE_INT_DEC
The data field holds a number that was
originally specified in decimal.
|
static int |
TYPE_INT_HEX
The data field holds a number that was
originally specified in hexadecimal (0xn).
|
static int |
TYPE_LAST_COLOR_INT
Identifies the end of integer values that were specified as color
constants.
|
static int |
TYPE_LAST_INT
Identifies the end of plain integer values.
|
static int |
TYPE_NULL
The value contains no data.
|
static int |
TYPE_REFERENCE
The data field holds a resource identifier.
|
static int |
TYPE_STRING
The string field holds string data.
|
Constructor and Description |
---|
TypedValue() |
Modifier and Type | Method and Description |
---|---|
static float |
applyDimension(int unit,
float value,
DisplayMetrics metrics)
Converts an unpacked complex data value holding a dimension to its final floating
point value.
|
CharSequence |
coerceToString()
Regardless of the actual type of the value, try to convert it to a
string value.
|
static String |
coerceToString(int type,
int data)
Perform type conversion as per
coerceToString() on an
explicitly supplied type and data. |
static float |
complexToDimension(int data,
DisplayMetrics metrics)
Converts a complex data value holding a dimension to its final floating
point value.
|
static float |
complexToDimensionNoisy(int data,
DisplayMetrics metrics) |
static int |
complexToDimensionPixelOffset(int data,
DisplayMetrics metrics)
Converts a complex data value holding a dimension to its final value
as an integer pixel offset.
|
static int |
complexToDimensionPixelSize(int data,
DisplayMetrics metrics)
Converts a complex data value holding a dimension to its final value
as an integer pixel size.
|
static float |
complexToFloat(int complex)
Retrieve the base value from a complex data integer.
|
static float |
complexToFraction(int data,
float base,
float pbase)
Converts a complex data value holding a fraction to its final floating
point value.
|
float |
getDimension(DisplayMetrics metrics)
Return the data for this value as a dimension.
|
float |
getFloat()
Return the data for this value as a float.
|
float |
getFraction(float base,
float pbase)
Return the data for this value as a fraction.
|
void |
setTo(TypedValue other) |
String |
toString()
Returns a string containing a concise, human-readable description of this
object.
|
public static final int TYPE_NULL
public static final int TYPE_REFERENCE
public static final int TYPE_ATTRIBUTE
public static final int TYPE_STRING
public static final int TYPE_FLOAT
public static final int TYPE_DIMENSION
public static final int TYPE_FRACTION
public static final int TYPE_FIRST_INT
TYPE_LAST_INT
means the
data field holds a generic integer value.public static final int TYPE_INT_DEC
public static final int TYPE_INT_HEX
public static final int TYPE_INT_BOOLEAN
public static final int TYPE_FIRST_COLOR_INT
public static final int TYPE_INT_COLOR_ARGB8
public static final int TYPE_INT_COLOR_RGB8
public static final int TYPE_INT_COLOR_ARGB4
public static final int TYPE_INT_COLOR_RGB4
public static final int TYPE_LAST_COLOR_INT
public static final int TYPE_LAST_INT
public static final int COMPLEX_UNIT_SHIFT
public static final int COMPLEX_UNIT_MASK
COMPLEX_UNIT_SHIFT
). This gives us 16 possible types, as
defined below.public static final int COMPLEX_UNIT_PX
TYPE_DIMENSION
complex unit: Value is raw pixels.public static final int COMPLEX_UNIT_DIP
TYPE_DIMENSION
complex unit: Value is Device Independent
Pixels.public static final int COMPLEX_UNIT_SP
TYPE_DIMENSION
complex unit: Value is a scaled pixel.public static final int COMPLEX_UNIT_PT
TYPE_DIMENSION
complex unit: Value is in points.public static final int COMPLEX_UNIT_IN
TYPE_DIMENSION
complex unit: Value is in inches.public static final int COMPLEX_UNIT_MM
TYPE_DIMENSION
complex unit: Value is in millimeters.public static final int COMPLEX_UNIT_FRACTION
TYPE_FRACTION
complex unit: A basic fraction of the overall
size.public static final int COMPLEX_UNIT_FRACTION_PARENT
TYPE_FRACTION
complex unit: A fraction of the parent size.public static final int COMPLEX_RADIX_SHIFT
public static final int COMPLEX_RADIX_MASK
COMPLEX_RADIX_SHIFT
). This give us 4 possible fixed point
representations as defined below.public static final int COMPLEX_RADIX_23p0
public static final int COMPLEX_RADIX_16p7
public static final int COMPLEX_RADIX_8p15
public static final int COMPLEX_RADIX_0p23
public static final int COMPLEX_MANTISSA_SHIFT
public static final int COMPLEX_MANTISSA_MASK
COMPLEX_MANTISSA_SHIFT
). This gives us 23 bits of precision;
the top bit is the sign.public static final int DENSITY_DEFAULT
density
is equal to this value, then the density should be
treated as the system's default density value: DisplayMetrics.DENSITY_DEFAULT
.public static final int DENSITY_NONE
density
is equal to this value, then there is no density
associated with the resource and it should not be scaled.public int type
public CharSequence string
public int data
type
public int assetCookie
public int resourceId
public int changingConfigurations
public int density
public final float getFloat()
TYPE_FLOAT
.public static float complexToFloat(int complex)
COMPLEX_MANTISSA_MASK
and COMPLEX_RADIX_MASK
fields of
the data to compute a floating point representation of the number they
describe. The units are ignored.complex
- A complex data value.public static float complexToDimension(int data, DisplayMetrics metrics)
TYPE_DIMENSION
.data
- A complex data value holding a unit, magnitude, and
mantissa.metrics
- Current display metrics to use in the conversion --
supplies display density and scaling information.public static int complexToDimensionPixelOffset(int data, DisplayMetrics metrics)
complexToDimension(int, android.util.DisplayMetrics)
, except the raw floating point value is
truncated to an integer (pixel) value.
The given data must be structured as a
TYPE_DIMENSION
.data
- A complex data value holding a unit, magnitude, and
mantissa.metrics
- Current display metrics to use in the conversion --
supplies display density and scaling information.public static int complexToDimensionPixelSize(int data, DisplayMetrics metrics)
complexToDimension(int, android.util.DisplayMetrics)
, except the raw floating point value is
converted to an integer (pixel) value for use as a size. A size
conversion involves rounding the base value, and ensuring that a
non-zero base value is at least one pixel in size.
The given data must be structured as a
TYPE_DIMENSION
.data
- A complex data value holding a unit, magnitude, and
mantissa.metrics
- Current display metrics to use in the conversion --
supplies display density and scaling information.public static float complexToDimensionNoisy(int data, DisplayMetrics metrics)
public static float applyDimension(int unit, float value, DisplayMetrics metrics)
TYPE_DIMENSION
.unit
- The unit to convert from.value
- The value to apply the unit to.metrics
- Current display metrics to use in the conversion --
supplies display density and scaling information.public float getDimension(DisplayMetrics metrics)
TYPE_DIMENSION
.metrics
- Current display metrics to use in the conversion --
supplies display density and scaling information.public static float complexToFraction(int data, float base, float pbase)
TYPE_FRACTION
.data
- A complex data value holding a unit, magnitude, and
mantissa.base
- The base value of this fraction. In other words, a
standard fraction is multiplied by this value.pbase
- The parent base value of this fraction. In other
words, a parent fraction (nn%p) is multiplied by this
value.public float getFraction(float base, float pbase)
TYPE_FRACTION
.base
- The base value of this fraction. In other words, a
standard fraction is multiplied by this value.pbase
- The parent base value of this fraction. In other
words, a parent fraction (nn%p) is multiplied by this
value.public final CharSequence coerceToString()
public static final String coerceToString(int type, int data)
coerceToString()
on an
explicitly supplied type and data.type
- The data type identifier.data
- The data value.public void setTo(TypedValue other)
public String toString()
Object
getClass().getName() + '@' + Integer.toHexString(hashCode())
See Writing a useful
toString
method
if you intend implementing your own toString
method.