Render Two images in ImageView in Android?

I am trying to write an application that will allow me to display multiple images on an ImageView in Android. I can find a way to fill it with the sigle bitmap. But there seems to be no way to get two images for rendering in ImageView (each of which takes up half of the rendering space). Any help would be greatly appreciated.

Thanks, De Costo.

+3
source share
3 answers

You can try to create one bitmap from several images.

, 32- ARGB, , Bitmap copyPixelsToBuffer(), createBitmap() setPixels().

, , BitmapFactory, decodeByteArray().

, ImageViews / . , .

.

+4

?

, SurfaceView.

, FrameLayout.

JAR, Android, ImageView.

+5

, . , . .

public static Bitmap mergeImage(Bitmap base, Bitmap overlay)
{
    int adWDelta = (int)(base.getWidth() - overlay.getWidth())/2 ;
    int adHDelta = (int)(base.getHeight() - overlay.getHeight())/2;

    Bitmap mBitmap = Bitmap.createBitmap(base.getWidth(), base.getHeight(), Config.ARGB_8888);
    Canvas canvas = new Canvas(mBitmap);
    canvas.drawBitmap(base, 0, 0, null);
    canvas.drawBitmap(overlay, adWDelta, adHDelta, null);

    return mBitmap;
}
+2

Source: https://habr.com/ru/post/1716018/


All Articles