My application shows a gridview list with some devices. Each devices has four states. I have a different types of devices images and four state images. I want to combine device images with state image and display in gridview. The images are stores in application resource. Images are shown using ImageView.
How i can do this ?
image1
image2
the output will be
edited new images
Try this works great with me
public Bitmap combineImages(int boxDrawableId , int closeDrawableId) {
Bitmap box = BitmapFactory.decodeResource(getResources(),boxDrawableId);
Bitmap close = BitmapFactory.decodeResource(getResources(), closeDrawableId);
Bitmap bitmapCreate = Bitmap.createBitmap(box.getWidth(), box.getHeight(), Bitmap.Config.ARGB_8888);
Canvas comboImage = new Canvas(bitmapCreate);
comboImage.drawBitmap(box, 0, 0, null);
comboImage.drawBitmap(close, box.getWidth()-close.getWidth(), box.getHeight()-close.getHeight(), null);
if (box != null) {
try {
box.recycle();
close.recycle();
box = null;
close = null;
} catch (Throwable e) {
}
}
return bitmapCreate;
}
How to call?
imgView.setImageBitmap(combineImages(R.drawable.box,R.drawable.close));
Output