Custom ImageView class not working with Picasso image downloading library

前端 未结 2 1727
暖寄归人
暖寄归人 2021-02-09 06:53

I have recently extended from an ImageView to create a CircularImageView class which makes the image circular with a coloured border. This is done via the onDraw(canvas) method

2条回答
  •  孤独总比滥情好
    2021-02-09 07:07

    When doing this with Picasso you should either:

    1. Apply the rounding as a Transformation so that the rounded bitmap is cached in memory, or
    2. Clamp the canvas with a shader in a custom ImageView subclass. Details on this technique were outlined by the ragin' cagin' Romain Guy on his blog

    Trying to pull the underlying Bitmap out of an ImageView is an anti-pattern. If you do need access to a Bitmap (and you don't, you should use one of the above), implement Target on your view whose onBitmapSuccess callback will provide it.

提交回复
热议问题