InlineContentView

public class InlineContentView
extends ViewGroup

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.inline.InlineContentView


This class represents a view that holds opaque content from another app that you can inline in your UI.

Since the content presented by this view is from another security domain,it is shown on a remote surface preventing the host application from accessing that content. Also the host application cannot interact with the inlined content by injecting touch events or clicking programmatically.

This view can be overlaid by other windows, i.e. redressed, but if this is the case the inlined UI would not be interactive. Sometimes this is desirable, e.g. animating transitions.

By default the surface backing this view is shown on top of the hosting window such that the inlined content is interactive. However, you can temporarily move the surface under the hosting window which could be useful in some cases, e.g. animating transitions. At this point the inlined content will not be interactive and the touch events would be delivered to your app.

Instances of this class are created by the platform and can be programmatically attached to your UI. Once the view is attached to the window, you may detach and reattach it to the window. It should work seamlessly from the hosting process's point of view.

Summary

Nested classes

interface InlineContentView.SurfaceControlCallback

Callback for observing the lifecycle of the surface control that manipulates the backing secure embedded UI surface. 

Inherited XML attributes

Inherited constants

Inherited fields

Public methods

SurfaceControl getSurfaceControl()

Gets the surface control.

boolean isZOrderedOnTop()
void onLayout(boolean changed, int l, int t, int r, int b)

Called from layout when this view should assign a size and position to each of its children.

void setClipBounds(Rect clipBounds)

Sets a rectangular area on this view to which the view will be clipped when it is drawn.

void setSurfaceControlCallback(InlineContentView.SurfaceControlCallback callback)

Sets a callback to observe the lifecycle of the surface control for managing the backing surface.

boolean setZOrderedOnTop(boolean onTop)

Controls whether the backing surface is placed on top of this view's window.

Protected methods

void onAttachedToWindow()

This is called when the view is attached to a window.

void onDetachedFromWindow()

This is called when the view is detached from a window.

Inherited methods

Public methods

getSurfaceControl

Added in API level 30
public SurfaceControl getSurfaceControl ()

Gets the surface control. If the surface is not created this method returns null.

Returns
SurfaceControl The surface control.

isZOrderedOnTop

Added in API level 30
public boolean isZOrderedOnTop ()

Returns
boolean Whether the surface backing this view appears on top of its parent.

onLayout

Added in API level 30
public void onLayout (boolean changed, 
                int l, 
                int t, 
                int r, 
                int b)

Called from layout when this view should assign a size and position to each of its children. Derived classes with children should override this method and call layout on each of their children.

Parameters
changed boolean: This is a new size or position for this view

l int: Left position, relative to parent

t int: Top position, relative to parent

r int: Right position, relative to parent

b int: Bottom position, relative to parent

setClipBounds

Added in API level 30
public void setClipBounds (Rect clipBounds)

Sets a rectangular area on this view to which the view will be clipped when it is drawn. Setting the value to null will remove the clip bounds and the view will draw normally, using its full bounds.

Parameters
clipBounds Rect: The rectangular area, in the local coordinates of this view, to which future drawing operations will be clipped.

setSurfaceControlCallback

Added in API level 30
public void setSurfaceControlCallback (InlineContentView.SurfaceControlCallback callback)

Sets a callback to observe the lifecycle of the surface control for managing the backing surface.

Parameters
callback InlineContentView.SurfaceControlCallback: The callback to set or null to clear.

setZOrderedOnTop

Added in API level 30
public boolean setZOrderedOnTop (boolean onTop)

Controls whether the backing surface is placed on top of this view's window. Normally, it is placed on top of the window, to allow interaction with the inlined UI. Via this method, you can place the surface below the window. This means that all of the contents of the window this view is in will be visible on top of its surface.

The Z ordering can be changed dynamically if the backing surface is created, otherwise the ordering would be applied at surface construction time.

Parameters
onTop boolean: Whether to show the surface on top of this view's window.

Returns
boolean

See also:

Protected methods

onAttachedToWindow

Added in API level 30
protected void onAttachedToWindow ()

This is called when the view is attached to a window. At this point it has a Surface and will start drawing. Note that this function is guaranteed to be called before onDraw(android.graphics.Canvas), however it may be called any time before the first onDraw -- including before or after onMeasure(int, int).
If you override this method you must call through to the superclass implementation.

onDetachedFromWindow

Added in API level 30
protected void onDetachedFromWindow ()

This is called when the view is detached from a window. At this point it no longer has a surface for drawing.
If you override this method you must call through to the superclass implementation.