How to get a Bitmap from a drawable defined in a xml?

前端 未结 3 1909
余生分开走
余生分开走 2020-12-24 05:20

How can I get the bitmap from a xml shape drawable. What am I doing wrong?

shadow.xml



        
3条回答
  •  情书的邮戳
    2020-12-24 05:43

    a ShapeDrawable doesn't have a bitmap associated with it - its sole purpose is to be drawn on a canvas. Until its draw method is called, it has no image. If you can get a canvas element at the place where you need to draw the shadow, you can draw it as a shapeDrawable, otherwise you might need a separate, empty view in your layout with the shadow as a background.

提交回复
热议问题