ImageView imageView = findViewById(R.id.image_view); imageView.buildDrawingCache(); Bitmap bitmap = imageView.getDrawingCache();
View view = findViewById(R.id.custom_view); view.setDrawingCacheEnabled(true); view.buildDrawingCache(); Bitmap bitmap = view.getDrawingCache(); view.setDrawingCacheEnabled(false);This example enables the drawing cache for a custom view object named view, builds the drawing cache, retrieves the cached bitmap, disables the drawing cache, and stores the bitmap in a variable for later use. The package library for the android.view.View class is android.view.