From 26819e76ff872087e088c871bf2f95ce7f518c75 Mon Sep 17 00:00:00 2001 From: Deepanshu Gupta Date: Sat, 9 Aug 2014 14:14:45 -0700 Subject: [PATCH] Resolve color xml attributes properly. [DO NOT MERGE] Color attributes were not being converted to int properly. The conversion to int was a simple string to int using base 16. This change resolves the colors as per #RGB, #ARGB, #RRGGBB or #AARRGGBB format depending on the length of the attribute. All values that begin with '#' are treated as colors. Bug: http://b.android.com/73845 Change-Id: I8ad089b821af1e290b9b95771b50213fe2fdd784 (cherry picked from commit 81564dfe60020fa977d39d168f682e9d61825660) --- tools/layoutlib/bridge/src/android/util/BridgeXmlPullAttributes.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/layoutlib/bridge/src/android/util/BridgeXmlPullAttributes.java b/tools/layoutlib/bridge/src/android/util/BridgeXmlPullAttributes.java index 6ac5b02916ae..691339e2d2ed 100644 --- a/tools/layoutlib/bridge/src/android/util/BridgeXmlPullAttributes.java +++ b/tools/layoutlib/bridge/src/android/util/BridgeXmlPullAttributes.java @@ -22,6 +22,7 @@ import com.android.internal.util.XmlUtils; import com.android.layoutlib.bridge.Bridge; import com.android.layoutlib.bridge.BridgeConstants; import com.android.layoutlib.bridge.android.BridgeContext; +import com.android.layoutlib.bridge.impl.ResourceHelper; import com.android.resources.ResourceType; import org.xmlpull.v1.XmlPullParser; @@ -210,6 +211,9 @@ public class BridgeXmlPullAttributes extends XmlPullAttributes { value = r.getValue(); } + if (value.charAt(0) == '#') { + return ResourceHelper.getColor(value); + } return XmlUtils.convertValueToInt(value, defaultValue); } -- 2.11.0