android: onDraw is called constantly

前端 未结 2 378
野性不改
野性不改 2021-01-21 11:50

I have a problem with a custom button. onDraw() gets called again and again, and I can\'t figure out why.

public class CircleButton extends Button {

    static          


        
2条回答
  •  终归单人心
    2021-01-21 12:19

    Sorry, dumb failure:

    this.getDefaultBitmap() had a setBackgroundColor(0x00000000); call in it which retriggered the onDraw.

    So kind of a recursion:

    onDraw() -> getDefaultBitmap() -> setBackgroundColor() -> onDraw

提交回复
热议问题