WebView

2026-09-20Loading rating…

1. Feature Description

RemoteWebView is a component for loading and displaying web pages, corresponding to ViewType.WEB_VIEW. By setting a complete URL, it renders the corresponding page on Pilot. It fits embedding online help docs, live data dashboards, H5 pages, etc.

Create it via RemoteViewHelper.createWebView():

val webView = helper.createWebView()

2. Common Properties

The following properties are set via the corresponding setXxx() methods. Unless noted otherwise, if the component is already mounted, call syncToRemote() after changing a property to make it take effect on Pilot.

Size & Layout (inherited from RemoteViewProvider)

MethodParamsDescription
setWidthIntWidth (dp); special values RemoteView.MATCH_PARENT(-1) / WRAP_CONTENT(-2)
setHeightIntHeight (dp); same special values
setMinSizeminWidth: Int, minHeight: IntMinimum size (dp)
setPaddingleft, top, right, bottom: IntPadding (dp)
setVisibilityVisibilityTypeVisibility: VISIBLE / INVISIBLE / GONE
setAlphaFloatOpacity, 0.0 – 1.0
setEnabledBooleanWhether enabled

Background & Shape (inherited from RemoteViewProvider)

MethodParamsDescription
setBackgroundIntSolid background color (ARGB Int)
setBackgroundShapeShapeDescriptorBackground shape: fill / stroke / corner radius

Web Properties

MethodParamsDescription
setUrlStringURL to load (must be a complete http / https address)

3. Tips

  1. The URL must be a complete address. setUrl requires a full address with the protocol scheme (e.g. https://www.dji.com); do not pass just www.dji.com or a relative path, otherwise it cannot load.
  2. Give the WebView explicit width and height. Specify a definite size with setWidth / setHeight (e.g. MATCH_PARENT width + fixed height 150) to avoid size collapse that makes the page invisible or renders abnormally.
  3. Background color must be ARGB Int. setBackground accepts an Int color value. Do not pass "#RRGGBB", "0xAARRGGBB", or R.color.xxx.
  4. Call syncToRemote() after changing a mounted component's properties. setXxx only updates the local cache; syncToRemote() batch-syncs to Pilot. If you configure properties before mounting, no extra call is needed.

4. Sample Code

In each group below, the code sample is on the left and the corresponding Pilot-side rendered preview is on the right.

01 Component Types (load a web page)

// Load a web page: complete URL + explicit size
val webView = helper.createWebView().apply {
    setWidth(RemoteView.MATCH_PARENT)
    setHeight(150)
    setUrl("https://developer.dji.com/doc/mobile-sdk-tutorial/en/")
}

For a full runnable example, see drawing/WebViewDrawer.ktopen in new window in the official Sample open-pilot-plugin-sample.

Last Updated: