From 9f357ae9f038b97e4426bf3707ca94624cdf5d75 Mon Sep 17 00:00:00 2001 From: Christopher Lane Date: Fri, 31 Oct 2014 14:52:06 -0700 Subject: Add convenience method for getting the complex unit type Bug: 18193912 Change-Id: Ida29c12c6c3f07ac0657e70d2ab07f2fc4f2cb20 --- core/java/android/util/TypedValue.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'core/java/android/util') 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 unit and value * are as in {@link #TYPE_DIMENSION}. -- cgit v1.1