java.lang.Object | |
↳ | android.util.TypedValue |
Container for a dynamically typed data value. Primarily used with
Resources
for holding resource values.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | COMPLEX_MANTISSA_MASK |
Complex data: mask to extract mantissa information (after shifting by
COMPLEX_MANTISSA_SHIFT
).
|
|||||||||
int | COMPLEX_MANTISSA_SHIFT | Complex data: bit location of mantissa information. | |||||||||
int | COMPLEX_RADIX_0p23 | Complex data: the mantissa magnitude is 0 bits -- i.e, 0x0.nnnnnn | |||||||||
int | COMPLEX_RADIX_16p7 | Complex data: the mantissa magnitude is 16 bits -- i.e, 0xnnnn.nn | |||||||||
int | COMPLEX_RADIX_23p0 | Complex data: the mantissa is an integral number -- i.e., 0xnnnnnn.0 | |||||||||
int | COMPLEX_RADIX_8p15 | Complex data: the mantissa magnitude is 8 bits -- i.e, 0xnn.nnnn | |||||||||
int | COMPLEX_RADIX_MASK |
Complex data: mask to extract radix information (after shifting by
COMPLEX_RADIX_SHIFT
).
|
|||||||||
int | COMPLEX_RADIX_SHIFT | Complex data: where the radix information is, telling where the decimal place appears in the mantissa. | |||||||||
int | COMPLEX_UNIT_DIP |
TYPE_DIMENSION
complex unit: Value is Device Independent
Pixels.
|
|||||||||
int | COMPLEX_UNIT_FRACTION |
TYPE_FRACTION
complex unit: A basic fraction of the overall
size.
|
|||||||||
int | COMPLEX_UNIT_FRACTION_PARENT |
TYPE_FRACTION
complex unit: A fraction of the parent size.
|
|||||||||
int | COMPLEX_UNIT_IN |
TYPE_DIMENSION
complex unit: Value is in inches.
|
|||||||||
int | COMPLEX_UNIT_MASK |
Complex data: mask to extract unit information (after shifting by
COMPLEX_UNIT_SHIFT
).
|
|||||||||
int | COMPLEX_UNIT_MM |
TYPE_DIMENSION
complex unit: Value is in millimeters.
|
|||||||||
int | COMPLEX_UNIT_PT |
TYPE_DIMENSION
complex unit: Value is in points.
|
|||||||||
int | COMPLEX_UNIT_PX |
TYPE_DIMENSION
complex unit: Value is raw pixels.
|
|||||||||
int | COMPLEX_UNIT_SHIFT | Complex data: bit location of unit information. | |||||||||
int | COMPLEX_UNIT_SP |
TYPE_DIMENSION
complex unit: Value is a scaled pixel.
|
|||||||||
int | DENSITY_DEFAULT |
If
density
is equal to this value, then the density should be
treated as the system's default density value:
DENSITY_DEFAULT
.
|
|||||||||
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 | TYPE_ATTRIBUTE | The data field holds an attribute resource identifier (referencing an attribute in the current theme style, not a resource entry). | |||||||||
int | TYPE_DIMENSION | The data field holds a complex number encoding a dimension value. | |||||||||
int | TYPE_FIRST_COLOR_INT | Identifies the start of integer values that were specified as color constants (starting with '#'). | |||||||||
int | TYPE_FIRST_INT | Identifies the start of plain integer values. | |||||||||
int | TYPE_FLOAT | The data field holds an IEEE 754 floating point number. | |||||||||
int | TYPE_FRACTION | The data field holds a complex number encoding a fraction of a container. | |||||||||
int | TYPE_INT_BOOLEAN | The data field holds 0 or 1 that was originally specified as "false" or "true". | |||||||||
int | TYPE_INT_COLOR_ARGB4 | The data field holds a color that was originally specified as #argb. | |||||||||
int | TYPE_INT_COLOR_ARGB8 | The data field holds a color that was originally specified as #aarrggbb. | |||||||||
int | TYPE_INT_COLOR_RGB4 | The data field holds a color that was originally specified as #rgb. | |||||||||
int | TYPE_INT_COLOR_RGB8 | The data field holds a color that was originally specified as #rrggbb. | |||||||||
int | TYPE_INT_DEC | The data field holds a number that was originally specified in decimal. | |||||||||
int | TYPE_INT_HEX | The data field holds a number that was originally specified in hexadecimal (0xn). | |||||||||
int | TYPE_LAST_COLOR_INT | Identifies the end of integer values that were specified as color constants. | |||||||||
int | TYPE_LAST_INT | Identifies the end of plain integer values. | |||||||||
int | TYPE_NULL | The value contains no data. | |||||||||
int | TYPE_REFERENCE | The data field holds a resource identifier. | |||||||||
int | TYPE_STRING | The string field holds string data. |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
assetCookie | Additional information about where the value came from; only set for strings. | |||||||||
|
changingConfigurations | If Value came from a resource, these are the configurations for which its contents can change. | |||||||||
|
data |
Basic data in the value, interpreted according to
type
|
|||||||||
|
density | If the Value came from a resource, this holds the corresponding pixel density. | |||||||||
|
resourceId | If Value came from a resource, this holds the corresponding resource id. | |||||||||
|
string | If the value holds a string, this is it. | |||||||||
|
type | The type held by this value, as defined by the constants here. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Converts an unpacked complex data value holding a dimension to its final floating
point value.
|
||||||||||
|
Regardless of the actual type of the value, try to convert it to a
string value.
|
||||||||||
|
Perform type conversion as per
coerceToString()
on an
explicitly supplied type and data.
|
||||||||||
|
Converts a complex data value holding a dimension to its final floating
point value.
|
||||||||||
|
Converts a complex data value holding a dimension to its final value
as an integer pixel offset.
|
||||||||||
|
Converts a complex data value holding a dimension to its final value
as an integer pixel size.
|
||||||||||
|
Retrieve the base value from a complex data integer.
|
||||||||||
|
Converts a complex data value holding a fraction to its final floating
point value.
|
||||||||||
|
Return the data for this value as a dimension.
|
||||||||||
|
Return the data for this value as a float.
|
||||||||||
|
Return the data for this value as a fraction.
|
||||||||||
|
|
||||||||||
|
Returns a string containing a concise, human-readable description of this
object.
|
[Expand]
Inherited Methods
|
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Complex data: mask to extract mantissa information (after shifting by
COMPLEX_MANTISSA_SHIFT
). This gives us 23 bits of precision;
the top bit is the sign.
Complex data: bit location of mantissa information.
Complex data: the mantissa magnitude is 0 bits -- i.e, 0x0.nnnnnn
Complex data: the mantissa magnitude is 16 bits -- i.e, 0xnnnn.nn
Complex data: the mantissa is an integral number -- i.e., 0xnnnnnn.0
Complex data: the mantissa magnitude is 8 bits -- i.e, 0xnn.nnnn
Complex data: mask to extract radix information (after shifting by
COMPLEX_RADIX_SHIFT
). This give us 4 possible fixed point
representations as defined below.
Complex data: where the radix information is, telling where the decimal place appears in the mantissa.
TYPE_DIMENSION
complex unit: Value is Device Independent
Pixels.
TYPE_FRACTION
complex unit: A basic fraction of the overall
size.
TYPE_FRACTION
complex unit: A fraction of the parent size.
TYPE_DIMENSION
complex unit: Value is in inches.
Complex data: mask to extract unit information (after shifting by
COMPLEX_UNIT_SHIFT
). This gives us 16 possible types, as
defined below.
TYPE_DIMENSION
complex unit: Value is in millimeters.
TYPE_DIMENSION
complex unit: Value is in points.
TYPE_DIMENSION
complex unit: Value is raw pixels.
Complex data: bit location of unit information.
TYPE_DIMENSION
complex unit: Value is a scaled pixel.
If
density
is equal to this value, then the density should be
treated as the system's default density value:
DENSITY_DEFAULT
.
If
density
is equal to this value, then there is no density
associated with the resource and it should not be scaled.
The data field holds an attribute resource identifier (referencing an attribute in the current theme style, not a resource entry).
The data field holds a complex number encoding a dimension value.
Identifies the start of integer values that were specified as color constants (starting with '#').
Identifies the start of plain integer values. Any type value
from this to
TYPE_LAST_INT
means the
data
field holds a generic integer value.
The data field holds an IEEE 754 floating point number.
The data field holds a complex number encoding a fraction of a container.
The data field holds 0 or 1 that was originally specified as "false" or "true".
The data field holds a color that was originally specified as #argb.
The data field holds a color that was originally specified as #aarrggbb.
The data field holds a color that was originally specified as #rgb.
The data field holds a color that was originally specified as #rrggbb.
The data field holds a number that was originally specified in decimal.
The data field holds a number that was originally specified in hexadecimal (0xn).
Identifies the end of integer values that were specified as color constants.
Identifies the end of plain integer values.
The value contains no data.
The data field holds a resource identifier.
The string field holds string data. In addition, if data is non-zero then it is the string block index of the string and assetCookie is the set of assets the string came from.
Additional information about where the value came from; only set for strings.
If Value came from a resource, these are the configurations for which its contents can change.
If the Value came from a resource, this holds the corresponding pixel density.
If Value came from a resource, this holds the corresponding resource id.
The type held by this value, as defined by the constants here. This tells you how to interpret the other fields in the object.
Converts an unpacked complex data value holding a dimension to its final floating
point value. The two parameters
unit
and
value
are as in
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. |
Regardless of the actual type of the value, try to convert it to a string value. For example, a color type will be converted to a string of the form #aarrggbb.
Perform type conversion as per
coerceToString()
on an
explicitly supplied type and data.
type | The data type identifier. |
---|---|
data | The data value. |
Converts a complex data value holding a dimension to its final floating
point 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. |
Converts a complex data value holding a dimension to its final value
as an integer pixel offset. This is the same as
complexToDimension(int, 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. |
Converts a complex data value holding a dimension to its final value
as an integer pixel size. This is the same as
complexToDimension(int, 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. |
Retrieve the base value from a complex data integer. This uses the
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. |
---|
Converts a complex data value holding a fraction to its final floating
point value. The given
data
must be structured as a
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. |
Return the data for this value as a dimension. Only use for values
whose type is
TYPE_DIMENSION
.
metrics | Current display metrics to use in the conversion -- supplies display density and scaling information. |
---|
Return the data for this value as a float. Only use for values
whose type is
TYPE_FLOAT
.
Return the data for this value as a fraction. Only use for values whose
type is
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. |
Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:
getClass().getName() + '@' + Integer.toHexString(hashCode())
See
Writing a useful
toString
method
if you intend implementing your own
toString
method.