我试图从自定义视图中获取位图,但我得到的是低质量的位图?
static Bitmap createTextWidgetImage(Context context, int widgetID) {
WidgetTextView widgetTextView = new WidgetTextView(context);
widgetTextView.setDrawingCacheEnabled(true);
Bundle bundle = AppWidgetManager.getInstance(context).getAppWidgetOptions(widgetID);
int minHeight = bundle.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT);
int minWidth = bundle.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH);
widgetTextView.measure(minWidth, minHeight);
widgetTextView.layout(0, 0, minWidth, minHeight);
Bitmap bitmap = Bitmap.createBitmap(minWidth, minHeight, Bitmap.Config.ARGB_8888);
widgetTextView.draw(new Canvas(bitmap));
return bitmap;
}