OiO.lk Blog Android Bitmap in Kotlin with Jetpack, won't draw the correct size
Android

Bitmap in Kotlin with Jetpack, won't draw the correct size


This has been driving me crazy all day. I have been trying to draw a full screen bitmap as the background for my custom view. The bitmap resolution is 2312×1080 the code right before I draw it shows both my canvas that I’m in and my bitmap are also 2312×1080 (these two log functions). But it keeps drawing the image so that the bottom and right are a little bit cut off. I made a checkerboard test image to check. For the life of me I can’t figure out what’s going wrong. Anyone have any ideas?

    Log.d("GridView", "Loaded bitmap dimensions - width: ${bitmap?.width}, height: ${bitmap?.height}")
    Log.d("GridView", "Canvas size - width: ${size.width}, height: ${size.height}")

    //draw the background image
    bitmap?.let { image ->
        drawImage(
            image = image,
            topLeft = Offset.Zero,

        )
    }



You need to sign in to view this answers

Exit mobile version