OSDN Git Service

Fix ShapeDrawable.inflateTag() to accept proper dimension specs for padding
authorPhil Dubach <phillipd@google.com>
Wed, 8 Jul 2009 16:43:49 +0000 (09:43 -0700)
committerPhil Dubach <phillipd@google.com>
Wed, 8 Jul 2009 16:43:49 +0000 (09:43 -0700)
ShapeDrawable.inflateTag() handles the 'padding' tag with the standard
attributes android:left, etc.  The attribute values for these standard
attributes should be dimension specifications, e.g. '4dp'.
ShapeDrawable.inflateTag() was wrongly parsing the attribute values as plain
integers.

graphics/java/android/graphics/drawable/ShapeDrawable.java

index d24194f..6677a35 100644 (file)
@@ -278,10 +278,15 @@ public class ShapeDrawable extends Drawable {
         if (name.equals("padding")) {
             TypedArray a = r.obtainAttributes(attrs,
                     com.android.internal.R.styleable.ShapeDrawablePadding);
-            setPadding(a.getInt(com.android.internal.R.styleable.ShapeDrawablePadding_left, 0),
-                       a.getInt(com.android.internal.R.styleable.ShapeDrawablePadding_top, 0),
-                       a.getInt(com.android.internal.R.styleable.ShapeDrawablePadding_right, 0),
-                       a.getInt(com.android.internal.R.styleable.ShapeDrawablePadding_bottom, 0));
+            setPadding(
+                    a.getDimensionPixelOffset(
+                            com.android.internal.R.styleable.ShapeDrawablePadding_left, 0),
+                    a.getDimensionPixelOffset(
+                            com.android.internal.R.styleable.ShapeDrawablePadding_top, 0),
+                    a.getDimensionPixelOffset(
+                            com.android.internal.R.styleable.ShapeDrawablePadding_right, 0),
+                    a.getDimensionPixelOffset(
+                            com.android.internal.R.styleable.ShapeDrawablePadding_bottom, 0));
             a.recycle();
             return true;
         }