Convert GradientDrawable to Bitmap

前端 未结 3 1111
误落风尘
误落风尘 2021-01-20 03:26

I have the following gradient (generated dynamically):

    GradientDrawable dynamicDrawable = new GradientDrawable();
    dynamicDrawable.setGradientType(Gra         


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-20 04:13

    • Create a mutable bitmap using Bitmap.createBitmap()
    • Create a Canvas based on the bitmap using new Canvas(bitmap)
    • Then call draw(canvas) on your GradientDrawable

提交回复
热议问题