I guess you could use the padding property to "move" the image, not sure if thats what you want to achieve
Android draw bitmap to specific position on ImageView
-
05-07-2023 - |
Вопрос
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 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);
}
Не связан с StackOverflow