diff options
author | Deepanshu Gupta <deepanshu@google.com> | 2015-10-05 14:37:54 -0700 |
---|---|---|
committer | Deepanshu Gupta <deepanshu@google.com> | 2015-10-05 16:08:54 -0700 |
commit | e5d3baf22f046d0a579128fc258f6b92e700ca02 (patch) | |
tree | 41d72c7b9d0c4012b1a3f1014c552a569d309cee | |
parent | f107709fb3f884f904deb1f3c09a88dd411ea30d (diff) | |
download | frameworks_base-e5d3baf22f046d0a579128fc258f6b92e700ca02.zip frameworks_base-e5d3baf22f046d0a579128fc258f6b92e700ca02.tar.gz frameworks_base-e5d3baf22f046d0a579128fc258f6b92e700ca02.tar.bz2 |
LayoutLib: Fix bitmap scaling.
Bug: http://b.android.com/187939
Change-Id: I20bf61746e8af3bb87ba9cfcc9bf58854ac7c5be
-rw-r--r-- | tools/layoutlib/bridge/src/android/content/res/BridgeResources.java | 8 | ||||
-rw-r--r-- | tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java | 1 |
2 files changed, 8 insertions, 1 deletions
diff --git a/tools/layoutlib/bridge/src/android/content/res/BridgeResources.java b/tools/layoutlib/bridge/src/android/content/res/BridgeResources.java index f4b1f2c..0e39243 100644 --- a/tools/layoutlib/bridge/src/android/content/res/BridgeResources.java +++ b/tools/layoutlib/bridge/src/android/content/res/BridgeResources.java @@ -18,6 +18,7 @@ package android.content.res; import com.android.SdkConstants; import com.android.ide.common.rendering.api.ArrayResourceValue; +import com.android.ide.common.rendering.api.DensityBasedResourceValue; import com.android.ide.common.rendering.api.LayoutLog; import com.android.ide.common.rendering.api.LayoutlibCallback; import com.android.ide.common.rendering.api.ResourceValue; @@ -661,13 +662,18 @@ public final class BridgeResources extends Resources { Pair<String, ResourceValue> value = getResourceValue(id, mPlatformResourceFlag); if (value != null) { - String v = value.getSecond().getValue(); + ResourceValue resVal = value.getSecond(); + String v = resVal.getValue(); if (v != null) { if (ResourceHelper.parseFloatAttribute(value.getFirst(), v, outValue, false /*requireUnit*/)) { return; } + if (resVal instanceof DensityBasedResourceValue) { + outValue.density = + ((DensityBasedResourceValue) resVal).getResourceDensity().getDpiValue(); + } // else it's a string outValue.type = TypedValue.TYPE_STRING; diff --git a/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java index d858953..60514b6 100644 --- a/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java @@ -59,6 +59,7 @@ import java.util.Set; if (opts.inPremultiplied) { bitmapCreateFlags.add(BitmapCreateFlags.PREMULTIPLIED); } + opts.inScaled = false; } try { |