Skip to main content

From Resources

VideoEditor SDK supports adding custom overlays from the resources. In this example, we add a custom "Grain" overlay.

WARNING: Be sure to put the drawables for the overlays in the res/drawable-nodpi folder. Otherwise, they will be scaled by the Android system.

Load overlay from resources#

Here, we create an OverlayAsset, providing it a unique id, the resource drawable, blend mode, and intensity.

Add overlay to AssetConfig#

To use the overlay, it must first be available in the SDK's backend. This is done by adding the overlay to the AssetConfig.

Configure UiConfigOverlay#

Here, we configure UiConfigOverlay and add a custom OverlayItem to the overlayList. Note how the OverlayItem uses the same id as the OverlayAsset. We also provide a name and a thumbnail ImageSource for the overlay.

class VideoAddOverlayFromResources(private val activity: AppCompatActivity) : Example(activity) {
override fun invoke() {
// In this example, we do not need access to the Uri(s) after the editor is closed
// so we pass false in the constructor
val settingsList = VideoEditorSettingsList(false)
// Set the source as the Uri of the video to be loaded
.configure<LoadSettings> {
it.source = activity.resourceUri(R.raw.skater)
// Create a custom overlay
val customOverlay = OverlayAsset("imgly_overlay_grain", R.drawable.imgly_overlay_grain, BlendMode.HARD_LIGHT, 0.4f)
// Add asset to AssetConfig
settingsList.configure<UiConfigOverlay> {
it.overlayList.add(OverlayItem("imgly_overlay_grain", "Grain", ImageSource.create(R.drawable.imgly_overlay_grain_thumb)))
// Start the video editor using VideoEditorBuilder
// The result will be obtained in onActivityResult() corresponding to EDITOR_REQUEST_CODE
.startActivityForResult(activity, EDITOR_REQUEST_CODE)
// Release the SettingsList once done
override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) {
intent ?: return
if (requestCode == EDITOR_REQUEST_CODE) {
// Wrap the intent into an EditorSDKResult
val result = EditorSDKResult(intent)
when (result.resultStatus) {
EditorSDKResult.Status.CANCELED -> showMessage("Editor cancelled")
EditorSDKResult.Status.EXPORT_DONE -> showMessage("Result saved at ${result.resultUri}")
else -> {