How can I override onDraw so that I take what would have been drawn (as a bitmap) and transform it?

后端 未结 3 1362
再見小時候
再見小時候 2020-12-16 04:59

The method below works, but it unfortunately, this method involves creating a bitmap the size of the entire screen - not just the area that is drawn to. If I use this to dra

3条回答
  •  有刺的猬
    2020-12-16 05:44

    I encountered something similar, where canvas.getWidth() and canvas.getHeight() returns the width and height of the whole screen instead of the view itself.

    Try to use the below instead:

    Bitmap bitmap=Bitmap.createBitmap(getWidth(), getHeight(), Config.ARGB_8888);
    

    For my case, getWidth() and getHeight() returns me the dimensions of my view. Good luck!

提交回复
热议问题