diff options
author | Christopher Lane <lanechr@google.com> | 2014-10-31 14:52:06 -0700 |
---|---|---|
committer | Christopher Lane <lanechr@google.com> | 2014-10-31 14:52:06 -0700 |
commit | 9f357ae9f038b97e4426bf3707ca94624cdf5d75 (patch) | |
tree | 580c6b7bd94acc3f0fd74803eb7eb97c1eab5f0f /core/java/android/util | |
parent | b9144cea5184c90534db75b47e3818a688e64d5b (diff) | |
download | frameworks_base-9f357ae9f038b97e4426bf3707ca94624cdf5d75.zip frameworks_base-9f357ae9f038b97e4426bf3707ca94624cdf5d75.tar.gz frameworks_base-9f357ae9f038b97e4426bf3707ca94624cdf5d75.tar.bz2 |
Add convenience method for getting the complex unit type
Bug: 18193912
Change-Id: Ida29c12c6c3f07ac0657e70d2ab07f2fc4f2cb20
Diffstat (limited to 'core/java/android/util')
-rw-r--r-- | core/java/android/util/TypedValue.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/core/java/android/util/TypedValue.java b/core/java/android/util/TypedValue.java index d42ed03..74d4245 100644 --- a/core/java/android/util/TypedValue.java +++ b/core/java/android/util/TypedValue.java @@ -312,6 +312,18 @@ public class TypedValue { } /** + * Return the complex unit type for this value. For example, a dimen type + * with value 12sp will return {@link #COMPLEX_UNIT_SP}. Only use for values + * whose type is {@link #TYPE_DIMENSION}. + * + * @return The complex unit type. + */ + public int getComplexUnit() + { + return COMPLEX_UNIT_MASK & (data>>TypedValue.COMPLEX_UNIT_SHIFT); + } + + /** * Converts an unpacked complex data value holding a dimension to its final floating * point value. The two parameters <var>unit</var> and <var>value</var> * are as in {@link #TYPE_DIMENSION}. |