ProgressBar

2026-09-20Loading rating…

1. Feature Description

RemoteProgressBar is a horizontal progress bar component for showing task progress, corresponding to ViewType.PROGRESS_BAR. It supports setting the current progress, the maximum value, and the bar color. It fits linear progress for uploading / downloading / loading, etc.

Create it via RemoteViewHelper.createProgressBar():

val progressBar = helper.createProgressBar()

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), i.e. the bar thickness; 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

Progress Bar Properties

MethodParamsDescription
setProgressIntCurrent progress value; must not exceed the maximum set by setMax
setMaxIntMaximum progress value, defaults to 100
setProgressColorIntProgress fill color (ARGB Int)

3. Tips

  1. Colors must be ARGB Int. setProgressColor / setBackground accept an Int color value (e.g. 0xFF1A8BFF.toInt() or Color.RED). Do not pass "#RRGGBB", "0xAARRGGBB", or R.color.xxx.
  2. 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.
  3. Progress percentage = progress / max. If you use a custom maximum other than 100, set it via setMax and make sure the value passed to setProgress does not exceed that maximum.
  4. The bar thickness is controlled by setHeight. For a horizontal progress bar, the height is the bar thickness; set the width to MATCH_PARENT to fill the container.

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 Progress & Style (value / thickness / color)

// Different progress values: 33% / 66% / 100%
val p33 = helper.createProgressBar().apply {
    setWidth(RemoteView.MATCH_PARENT); setHeight(12)
    setMax(100); setProgress(33); setProgressColor(0xFF1A8BFF.toInt())
}
val p66 = helper.createProgressBar().apply {
    setWidth(RemoteView.MATCH_PARENT); setHeight(12)
    setMax(100); setProgress(66); setProgressColor(0xFF1A8BFF.toInt())
}
val p100 = helper.createProgressBar().apply {
    setWidth(RemoteView.MATCH_PARENT); setHeight(12)
    setMax(100); setProgress(100); setProgressColor(0xFF1A8BFF.toInt())
}

// Different thickness (via setHeight): 4dp / 8dp / 12dp
val thin = helper.createProgressBar().apply {
    setWidth(RemoteView.MATCH_PARENT); setHeight(4)
    setProgress(33); setProgressColor(0xFF1A8BFF.toInt())
}
val medium = helper.createProgressBar().apply {
    setWidth(RemoteView.MATCH_PARENT); setHeight(8)
    setProgress(66); setProgressColor(0xFF1A8BFF.toInt())
}
val thick = helper.createProgressBar().apply {
    setWidth(RemoteView.MATCH_PARENT); setHeight(12)
    setProgress(100); setProgressColor(0xFF1A8BFF.toInt())
}

// Different colors: blue / orange / red
val blue = helper.createProgressBar().apply {
    setWidth(RemoteView.MATCH_PARENT); setHeight(12)
    setProgress(33); setProgressColor(0xFF1A8BFF.toInt())
}
val orange = helper.createProgressBar().apply {
    setWidth(RemoteView.MATCH_PARENT); setHeight(12)
    setProgress(66); setProgressColor(0xFFFF8100.toInt())
}
val red = helper.createProgressBar().apply {
    setWidth(RemoteView.MATCH_PARENT); setHeight(12)
    setProgress(88); setProgressColor(0xFFE41F29.toInt())
}

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

Last Updated: