android - Combine multiple drawables -
i have multiple drawables , want combine 1 drawable (for example, 4 squares create 1 big square, windows logo :)). how can this?
you can using tablelayout
or linearlayout
s. however, if want create single image usin within imageview
have create bitmap
manually; not hard:
bitmap square1 = bitmapfactory.decoderesource(getresources(), r.drawable.square1); bitmap square2 = bitmapfactory.decoderesource(getresources(), r.drawable.square2); bitmap square3 = bitmapfactory.decoderesource(getresources(), r.drawable.square3); bitmap square4 = bitmapfactory.decoderesource(getresources(), r.drawable.square4); bitmap big = bitmap.createbitmap(square1.getwidth() * 2, square1.getheight() * 2, bitmap.config.argb_8888); canvas canvas = new canvas(big); canvas.drawbitmap(square1, 0, 0, null); canvas.drawbitmap(square2, square1.getwidth(), 0, null); canvas.drawbitmap(square3, 0, square1.getheight(), null); canvas.drawbitmap(square4, square1.getwidth(), square1.getheight(), null);
i have not compile code above; i'm showing how can done. i'm assuming have square drawables same dimensions. notice bitmap called big
can used wherever want (e.g. imageview.setimagebitmap()
).
Comments
Post a Comment