Android: How to redraw a graphic element?

前端 未结 2 1087
长情又很酷
长情又很酷 2020-12-16 12:54

I have created a class RoundIcon which extends View and the class contains setIconImage() method:

public void setIconImage(int imageFromResources) {
    icon         


        
相关标签:
2条回答
  • 2020-12-16 13:46

    Definitely call invalidate instead of refreshDrawableState(). You might want to check what thread your on and if on a background call postInvalidate().

    0 讨论(0)
  • 2020-12-16 13:47

    Try calling View.invalidate() instead of View.refreshDrawableState()

    Invalidate will tell the view that all of the pixels in the view need to be redrawn, if you are only updating a smaller area of the view look into the invalidate(Rect) overload for a performance boost.

    0 讨论(0)
提交回复
热议问题