Question

I have an ImageView sized 400 * 400 and a Bitmap sized 400 * 350.

I want to draw this Bitmap to the ImageView so that there is a blank region on the top of the ImageView. That is to say, draw from the coordinate (0, 50).

I am trying to find an API in ImageView like:

imageView.setImageBitmap(int startXPos, int startYPos, int width, int height, Bitmap, bitmap);

But I only find one

imageView.setImageBitmap(Bitmap bitmap);

Thanks!

Was it helpful?

Solution

I guess you could use the padding property to "move" the image, not sure if thats what you want to achieve

OTHER TIPS

I solved the problem by overriding the onDraw() method. There is an API in Canvas class that enable the user to specify the coordinates to draw the bitmap.

@Override
public void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    canvas.drawBitmap(bitmap, left, top, paint);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top