目前我正在使用 view.getDrawingCache(),但是现在获取绘图缓存的方法已经被弃用
view.setDrawingCacheEnabled(true);
Bitmap bitamp = Bitmap.createBitmap(view.getDrawingCache())
view.setDrawingCacheEnabled(false);
view.getDrawingCache()在Android API 28中已被弃用
Java代码的解决方案出现了错误Callback
@RequiresApi(api = Build.VERSION_CODES.O)
public static void getBitmapFormView(View view, Activity activity, Callback callback) {
Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
int[] locations = new int[2];
view.getLocationInWindow(locations);
Rect rect = new Rect(locations[0], locations[1], locations[0] + view.getWidth(), locations[1] + view.getHeight());
PixelCopy.request(activity.getWindow(), rect, bitmap, copyResult -> {
if (copyResult == PixelCopy.SUCCESS) {
callback.onResult(bitmap);
}
}, new Handler(Looper.getMainLooper()));
}
无法解析回调函数
- 活动(Activity)
- 窗口(Window)
- 处理程序(Handler)
哪个是回调函数的超类?