Android transparent canvas (surfaceview)

前端 未结 4 1434
萌比男神i
萌比男神i 2020-12-08 12:08

I\'ve got a panel which is placed on top of another view via a relativelayout.

I would like to give this panel a transparent background, but didn\'t find the correct

4条回答
  •  时光取名叫无心
    2020-12-08 12:53

    In the constructor:

    setZOrderOnTop(true);
    

    After holder.addCallback(this):

    holder.setFormat(PixelFormat.TRANSPARENT);
    

    At the beginning of drawing:

    canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
    

提交回复
热议问题