diff --git a/src/api-impl/android/graphics/drawable/BitmapDrawable.java b/src/api-impl/android/graphics/drawable/BitmapDrawable.java index 18ec53bf..972b2d0f 100644 --- a/src/api-impl/android/graphics/drawable/BitmapDrawable.java +++ b/src/api-impl/android/graphics/drawable/BitmapDrawable.java @@ -1,15 +1,28 @@ package android.graphics.drawable; +import java.io.IOException; + +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; + +import com.android.internal.R; + import android.content.res.Resources; +import android.content.res.Resources.Theme; +import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Rect; import android.graphics.RectF; +import android.util.AttributeSet; public class BitmapDrawable extends Drawable { private Bitmap bitmap; + public BitmapDrawable() { + } + public BitmapDrawable(Resources res, Bitmap bitmap) { this.bitmap = bitmap; } @@ -23,4 +36,13 @@ public class BitmapDrawable extends Drawable { return bitmap; } + public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs, Theme theme) + throws XmlPullParserException, IOException { + final TypedArray a = r.obtainAttributes(attrs, R.styleable.BitmapDrawable); + if (a.hasValue(R.styleable.BitmapDrawable_src)) { + paintable = a.getDrawable(R.styleable.BitmapDrawable_src).paintable; + } + a.recycle(); + } + } diff --git a/src/api-impl/android/graphics/drawable/Drawable.java b/src/api-impl/android/graphics/drawable/Drawable.java index 97fe4f9a..1689bb1e 100644 --- a/src/api-impl/android/graphics/drawable/Drawable.java +++ b/src/api-impl/android/graphics/drawable/Drawable.java @@ -123,6 +123,10 @@ public class Drawable { return drawable; } else if ("shape".equals(parser.getName())) { return new GradientDrawable(); + } else if ("bitmap".equals(parser.getName())) { + BitmapDrawable drawable = new BitmapDrawable(); + drawable.inflate(resources, parser, parser, null); + return drawable; } return null; }