Android: how to set the height/width of the src image of a ImageButton?

前端 未结 5 1305
野的像风
野的像风 2021-02-13 02:14

Android: how to set the height/width of the image(src image intead of the background) of a ImageButton?

I want to set the height/width of the top level image(not the bac

5条回答
  •  囚心锁ツ
    2021-02-13 02:42

    You can use Bitmap.createScaledBitmap to scale the image to the size you want.

    Bitmap image = ... //load image from your source
    image = Bitmap.createScaledBitmap(image, desiredHeight, desiredWidth, true);
    

提交回复
热议问题