Package android.util
Class TypedValue
java.lang.Object
android.util.TypedValue
Container for a dynamically typed data value. Primarily used with
Resources for holding resource values.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intComplex data: mask to extract mantissa information (after shifting byCOMPLEX_MANTISSA_SHIFT).static final intComplex data: bit location of mantissa information.static final intComplex data: the mantissa magnitude is 0 bits -- i.e, 0x0.nnnnnnstatic final intComplex data: the mantissa magnitude is 16 bits -- i.e, 0xnnnn.nnstatic final intComplex data: the mantissa is an integral number -- i.e., 0xnnnnnn.0static final intComplex data: the mantissa magnitude is 8 bits -- i.e, 0xnn.nnnnstatic final intComplex data: mask to extract radix information (after shifting byCOMPLEX_RADIX_SHIFT).static final intComplex data: where the radix information is, telling where the decimal place appears in the mantissa.static final intTYPE_DIMENSIONcomplex unit: Value is Device Independent Pixels.static final intTYPE_FRACTIONcomplex unit: A basic fraction of the overall size.static final intTYPE_FRACTIONcomplex unit: A fraction of the parent size.static final intTYPE_DIMENSIONcomplex unit: Value is in inches.static final intComplex data: mask to extract unit information (after shifting byCOMPLEX_UNIT_SHIFT).static final intTYPE_DIMENSIONcomplex unit: Value is in millimeters.static final intTYPE_DIMENSIONcomplex unit: Value is in points.static final intTYPE_DIMENSIONcomplex unit: Value is raw pixels.static final intComplex data: bit location of unit information.static final intTYPE_DIMENSIONcomplex unit: Value is a scaled pixel.static final intTYPE_NULLdata indicating the value was explicitly set to null.static final intTYPE_NULLdata indicating the value was not specified.static final intIf density is equal to this value, then the density should be treated as the system's default density value:static final intIf density is equal to this value, then there is no density associated with the resource and it should not be scaled.intThe type held by this value, as defined by the constants here.static final intThe data field holds an attribute resource identifier (referencing an attribute in the current theme style, not a resource entry).static final intThe data field holds a complex number encoding a dimension value.static final intThe data an attribute resource identifier, which needs to be resolved before it can be used like a TYPE_ATTRIBUTE.static final intThe data holds a dynamic res table reference, which needs to be resolved before it can be used like TYPE_REFERENCEstatic final intIdentifies the start of integer values that were specified as color constants (starting with '#').static final intIdentifies the start of plain integer values.static final intThe data field holds an IEEE 754 floating point number.static final intThe data field holds a complex number encoding a fraction of a container.static final intThe data field holds 0 or 1 that was originally specified as "false" or "true".static final intThe data field holds a color that was originally specified as #argb.static final intThe data field holds a color that was originally specified as #aarrggbb.static final intThe data field holds a color that was originally specified as #rgb.static final intThe data field holds a color that was originally specified as #rrggbb.static final intThe data field holds a number that was originally specified in decimal.static final intThe data field holds a number that was originally specified in hexadecimal (0xn).static final intIdentifies the end of integer values that were specified as color constants.static final intIdentifies the end of plain integer values.static final intThe value contains no data.static final intThe data field holds a resource identifier.static final intThe string field holds string data. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcoerceToString(int type, int data) Perform type conversion as per coerceToString on an explicitly supplied type and data.static floatcomplexToFloat(int complex) Retrieve the base value from a complex data integer.
-
Field Details
-
TYPE_NULL
public static final int TYPE_NULLThe value contains no data.- See Also:
-
TYPE_REFERENCE
public static final int TYPE_REFERENCEThe data field holds a resource identifier.- See Also:
-
TYPE_ATTRIBUTE
public static final int TYPE_ATTRIBUTEThe data field holds an attribute resource identifier (referencing an attribute in the current theme style, not a resource entry).- See Also:
-
TYPE_STRING
public static final int TYPE_STRINGThe 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.- See Also:
-
TYPE_FLOAT
public static final int TYPE_FLOATThe data field holds an IEEE 754 floating point number.- See Also:
-
TYPE_DIMENSION
public static final int TYPE_DIMENSIONThe data field holds a complex number encoding a dimension value.- See Also:
-
TYPE_FRACTION
public static final int TYPE_FRACTIONThe data field holds a complex number encoding a fraction of a container.- See Also:
-
TYPE_DYNAMIC_REFERENCE
public static final int TYPE_DYNAMIC_REFERENCEThe data holds a dynamic res table reference, which needs to be resolved before it can be used like TYPE_REFERENCE- See Also:
-
TYPE_DYNAMIC_ATTRIBUTE
public static final int TYPE_DYNAMIC_ATTRIBUTEThe data an attribute resource identifier, which needs to be resolved before it can be used like a TYPE_ATTRIBUTE.- See Also:
-
TYPE_FIRST_INT
public static final int TYPE_FIRST_INTIdentifies the start of plain integer values. Any type value from this toTYPE_LAST_INTmeans the data field holds a generic integer value.- See Also:
-
TYPE_INT_DEC
public static final int TYPE_INT_DECThe data field holds a number that was originally specified in decimal.- See Also:
-
TYPE_INT_HEX
public static final int TYPE_INT_HEXThe data field holds a number that was originally specified in hexadecimal (0xn).- See Also:
-
TYPE_INT_BOOLEAN
public static final int TYPE_INT_BOOLEANThe data field holds 0 or 1 that was originally specified as "false" or "true".- See Also:
-
TYPE_FIRST_COLOR_INT
public static final int TYPE_FIRST_COLOR_INTIdentifies the start of integer values that were specified as color constants (starting with '#').- See Also:
-
TYPE_INT_COLOR_ARGB8
public static final int TYPE_INT_COLOR_ARGB8The data field holds a color that was originally specified as #aarrggbb.- See Also:
-
TYPE_INT_COLOR_RGB8
public static final int TYPE_INT_COLOR_RGB8The data field holds a color that was originally specified as #rrggbb.- See Also:
-
TYPE_INT_COLOR_ARGB4
public static final int TYPE_INT_COLOR_ARGB4The data field holds a color that was originally specified as #argb.- See Also:
-
TYPE_INT_COLOR_RGB4
public static final int TYPE_INT_COLOR_RGB4The data field holds a color that was originally specified as #rgb.- See Also:
-
TYPE_LAST_COLOR_INT
public static final int TYPE_LAST_COLOR_INTIdentifies the end of integer values that were specified as color constants.- See Also:
-
TYPE_LAST_INT
public static final int TYPE_LAST_INTIdentifies the end of plain integer values.- See Also:
-
COMPLEX_UNIT_SHIFT
public static final int COMPLEX_UNIT_SHIFTComplex data: bit location of unit information.- See Also:
-
COMPLEX_UNIT_MASK
public static final int COMPLEX_UNIT_MASKComplex data: mask to extract unit information (after shifting byCOMPLEX_UNIT_SHIFT). This gives us 16 possible types, as defined below.- See Also:
-
COMPLEX_UNIT_PX
public static final int COMPLEX_UNIT_PXTYPE_DIMENSIONcomplex unit: Value is raw pixels.- See Also:
-
COMPLEX_UNIT_DIP
public static final int COMPLEX_UNIT_DIPTYPE_DIMENSIONcomplex unit: Value is Device Independent Pixels.- See Also:
-
COMPLEX_UNIT_SP
public static final int COMPLEX_UNIT_SPTYPE_DIMENSIONcomplex unit: Value is a scaled pixel.- See Also:
-
COMPLEX_UNIT_PT
public static final int COMPLEX_UNIT_PTTYPE_DIMENSIONcomplex unit: Value is in points.- See Also:
-
COMPLEX_UNIT_IN
public static final int COMPLEX_UNIT_INTYPE_DIMENSIONcomplex unit: Value is in inches.- See Also:
-
COMPLEX_UNIT_MM
public static final int COMPLEX_UNIT_MMTYPE_DIMENSIONcomplex unit: Value is in millimeters.- See Also:
-
COMPLEX_UNIT_FRACTION
public static final int COMPLEX_UNIT_FRACTIONTYPE_FRACTIONcomplex unit: A basic fraction of the overall size.- See Also:
-
COMPLEX_UNIT_FRACTION_PARENT
public static final int COMPLEX_UNIT_FRACTION_PARENTTYPE_FRACTIONcomplex unit: A fraction of the parent size.- See Also:
-
COMPLEX_RADIX_SHIFT
public static final int COMPLEX_RADIX_SHIFTComplex data: where the radix information is, telling where the decimal place appears in the mantissa.- See Also:
-
COMPLEX_RADIX_MASK
public static final int COMPLEX_RADIX_MASKComplex data: mask to extract radix information (after shifting byCOMPLEX_RADIX_SHIFT). This give us 4 possible fixed point representations as defined below.- See Also:
-
COMPLEX_RADIX_23p0
public static final int COMPLEX_RADIX_23p0Complex data: the mantissa is an integral number -- i.e., 0xnnnnnn.0- See Also:
-
COMPLEX_RADIX_16p7
public static final int COMPLEX_RADIX_16p7Complex data: the mantissa magnitude is 16 bits -- i.e, 0xnnnn.nn- See Also:
-
COMPLEX_RADIX_8p15
public static final int COMPLEX_RADIX_8p15Complex data: the mantissa magnitude is 8 bits -- i.e, 0xnn.nnnn- See Also:
-
COMPLEX_RADIX_0p23
public static final int COMPLEX_RADIX_0p23Complex data: the mantissa magnitude is 0 bits -- i.e, 0x0.nnnnnn- See Also:
-
COMPLEX_MANTISSA_SHIFT
public static final int COMPLEX_MANTISSA_SHIFTComplex data: bit location of mantissa information.- See Also:
-
COMPLEX_MANTISSA_MASK
public static final int COMPLEX_MANTISSA_MASKComplex data: mask to extract mantissa information (after shifting byCOMPLEX_MANTISSA_SHIFT). This gives us 23 bits of precision; the top bit is the sign.- See Also:
-
DATA_NULL_UNDEFINED
public static final int DATA_NULL_UNDEFINEDTYPE_NULLdata indicating the value was not specified.- See Also:
-
DATA_NULL_EMPTY
public static final int DATA_NULL_EMPTYTYPE_NULLdata indicating the value was explicitly set to null.- See Also:
-
DENSITY_DEFAULT
public static final int DENSITY_DEFAULTIf density is equal to this value, then the density should be treated as the system's default density value:- See Also:
-
DENSITY_NONE
public static final int DENSITY_NONEIf density is equal to this value, then there is no density associated with the resource and it should not be scaled.- See Also:
-
type
public int typeThe type held by this value, as defined by the constants here. This tells you how to interpret the other fields in the object.
-
-
Constructor Details
-
TypedValue
public TypedValue()
-
-
Method Details
-
complexToFloat
public static float complexToFloat(int complex) Retrieve the base value from a complex data integer. This uses theCOMPLEX_MANTISSA_MASKandCOMPLEX_RADIX_MASKfields of the data to compute a floating point representation of the number they describe. The units are ignored.- Parameters:
complex- A complex data value.- Returns:
- A floating point value corresponding to the complex data.
-
coerceToString
Perform type conversion as per coerceToString on an explicitly supplied type and data.- Parameters:
type- The data type identifier.data- The data value.- Returns:
- String The coerced string value. If the value is null or the type is not known, null is returned.
-