Reputation: 7179
In my application I have a 9.png
. If I set it in XML via
android:background="@drawable/image"
it works great but if I use this code: bubble.setBackgroundResource(R.drawable.image)
to set the 9.png programmaticly it does not work. Any ideas why?
Upvotes: 0
Views: 217
Reputation: 3679
Try this :
private Drawable displayNinePatch(Bitmap bitmap, Context context) {
byte[] chunk = bitmap.getNinePatchChunk();
if(NinePatch.isNinePatchChunk(chunk)) {
return new NinePatchDrawable(context.getResources(), bitmap, chunk, new Rect(), null);
} else return new BitmapDrawable(bitmap);
}
Upvotes: 1
Reputation: 6533
img_image.setBackground(getResources().getDrawable( R.drawable.icon));
Upvotes: 0