am fb5877a4: am 4c0f0e6c: Merge "Fix setting styles in custom views." into lmp-dev automerge: 5c22a79 automerge: 7d3d5fe automerge: 1f33b2f

* commit 'fb5877a4e7ac63df741489484f1642af0d592397':
  Fix setting styles in custom views.
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
index 3d3afa4..aeb70e9 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
@@ -479,6 +479,23 @@
         StyleResourceValue style = getStyleByDynamicId(resid);
 
         if (style == null) {
+            // In some cases, style may not be a dynamic id, so we do a full search.
+            ResourceReference ref = resolveId(resid);
+            if (ref != null) {
+                if (ref.isFramework()) {
+                    ref =
+                      getRenderResources().getFrameworkResource(ResourceType.STYLE, ref.getName());
+                } else {
+                    ref =
+                      getRenderResources().getProjectResource(ResourceType.STYLE, ref.getName());
+                }
+                if (ref instanceof StyleResourceValue) {
+                    style = ((StyleResourceValue) ref);
+                }
+            }
+        }
+
+        if (style == null) {
             throw new Resources.NotFoundException();
         }