1

Hi all android developers! I want use Arc progress view in Widget to implement action progress circular timer. But, widget not support custom views. I found following way Android: AppWidget with custom view not working but always bitmap is null. Anybody know how to create custom view and get its bitmap without add it to window?

Community
  • 1
  • 1
SBotirov
  • 13,872
  • 7
  • 59
  • 81

1 Answers1

2
CustomView view = new CustomView(context);
view.measure(250, 250);
view.layout(0, 0, 250, 250);
view.setDrawingCacheEnabled(true);
Bitmap bitmap = view.getDrawingCache();
remoteViews.setImageViewBitmap(R.id.myImageView, bitmap);

//PUSH WIDGET UPDATE 
Naruto Uzumaki
  • 2,019
  • 18
  • 37
  • 1
    better do `view.measure(View.MeasureSpec.makeMeasureSpec(250, EXACTLY), View.MeasureSpec.makeMeasureSpec(250, EXACTLY))` – sulai Feb 07 '20 at 15:48