문제

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!

도움이 되었습니까?

해결책

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

다른 팁

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);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top