{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

ViewInteractionCapture

public final class ViewInteractionCapture


Summary

Public constructors

Public methods

static final @ExperimentalTestApi @RequiresApi(value = 16) @NonNull Bitmap

Captures an image of the matching view into a {@link Bitmap}.

Public constructors

ViewInteractionCapture

public final ViewInteractionCapture()

Public methods

ViewInteractionCapture.captureToBitmap

@ExperimentalTestApi
@RequiresApi(value = 16)
public static final @NonNull Bitmap ViewInteractionCapture.captureToBitmap(
    @NonNull ViewInteraction receiver
)

Captures an image of the matching view into a {@link Bitmap}.

For devices below {@link Build.VERSION_CODES#O} (or if the view's window cannot be determined), the image is obtained using {@link View#draw}. Otherwise, {@link PixelCopy} is used.

This method will also enable {@link HardwareRendererCompat#setDrawingEnabled(boolean)} if required.

This API is currently experimental and subject to change or removal.