BitmapDrawable deprecated alternative

前端 未结 3 2118
星月不相逢
星月不相逢 2020-12-01 02:37

I have the following code that will rotate a drawable by a set amount of degrees.

    public Drawable rotateDrawable(float angle, Context context)
    {
             


        
相关标签:
3条回答
  • 2020-12-01 02:56

    Try this Once.

    1. In Activity

      BitmapDrawable background = new BitmapDrawable(this.getResources(), blurImageBg);
      
    2. In Fragment

      BitmapDrawable background = new BitmapDrawable(getActivity(), blurImageBg);
      
    3. In Adapter or else

      BitmapDrawable background = new BitmapDrawable(context.getResources(), blurImageBg);
      
    0 讨论(0)
  • 2020-12-01 02:59

    Do this instead:

    return new BitmapDrawable(context.getResources(), canvasBitmap);
    
    0 讨论(0)
  • 2020-12-01 03:12

    Kotlin code for BitmapDrawable:

    var bitmapDrawable = BitmapDrawable(resources,bitmapObj)
    
    0 讨论(0)
提交回复
热议问题