Android.Print.PrintDocumentAdapter.OnLayout Method
Called when the print attributes (page size, density, etc) changed giving you a chance to layout the content such that it matches the new constraints.

Syntax

[Android.Runtime.Register("onLayout", "(Landroid/print/PrintAttributes;Landroid/print/PrintAttributes;Landroid/os/CancellationSignal;Landroid/print/PrintDocumentAdapter$LayoutResultCallback;Landroid/os/Bundle;)V", "GetOnLayout_Landroid_print_PrintAttributes_Landroid_print_PrintAttributes_Landroid_os_CancellationSignal_Landroid_print_PrintDocumentAdapter_LayoutResultCallback_Landroid_os_Bundle_Handler")]
public abstract void OnLayout (PrintAttributes oldAttributes, PrintAttributes newAttributes, Android.OS.CancellationSignal cancellationSignal, PrintDocumentAdapter.LayoutResultCallback callback, Android.OS.Bundle extras)

See Also

Android.OS.CancellationSignal
PrintDocumentAdapter.ExtraPrintPreview

Parameters

oldAttributes
The old print attributes.
newAttributes
The new print attributes.
cancellationSignal
Signal for observing cancel layout requests.
callback
Callback to inform the system for the layout result.
extras
Additional information about how to layout the content.

Remarks

Called when the print attributes (page size, density, etc) changed giving you a chance to layout the content such that it matches the new constraints. This method is invoked on the main thread.

java Example

 cancellationSignal.setOnCancelListener(new OnCancelListener() {
     @Override
     public void onCancel() {
         // Cancel layout
     }
 });
 

After you are done laying out, you must invoke: NoType:android/print/PrintDocumentAdapter$LayoutResultCallback;Href=../../../reference/android/print/PrintDocumentAdapter.LayoutResultCallback.html#onLayoutFinished(android.print.PrintDocumentInfo, boolean) with the last argument true or false depending on whether the layout changed the content or not, respectively; or NoType:android/print/PrintDocumentAdapter$LayoutResultCallback;Href=../../../reference/android/print/PrintDocumentAdapter.LayoutResultCallback.html#onLayoutFailed(java.lang.CharSequence), if an error occurred; or NoType:android/print/PrintDocumentAdapter$LayoutResultCallback;Href=../../../reference/android/print/PrintDocumentAdapter.LayoutResultCallback.html#onLayoutCancelled() if layout was cancelled in a response to a cancellation request via the passed in Android.OS.CancellationSignal. Note that you must call one of the methods of the given callback for this method to be considered complete which is you will not receive any calls to this adapter until the current layout operation is complete by invoking a method on the callback instance. The callback methods can be invoked from an arbitrary thread.

One of the arguments passed to this method is a Android.OS.CancellationSignal which is used to propagate requests from the system to your application for canceling the current layout operation. For example, a cancellation may be requested if the user changes a print option that may affect layout while you are performing a layout operation. In such a case the system will make an attempt to cancel the current layout as another one will have to be performed. Typically, you should register a cancellation callback in the cancellation signal. The cancellation callback will not be made on the main thread and can be registered as follows:

Note: If the content is large and a layout will be performed, it is a good practice to schedule the work on a dedicated thread and register an observer in the provided Android.OS.CancellationSignal upon invocation of which you should stop the layout.

[Android Documentation]

Requirements

Namespace: Android.Print
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0