The CreativeEditor SDK provides a rotation feature for Android apps. Image rotation is a core editing feature that Android users expect in photo apps.
The CreativeEditor SDK offers straightforward methods for incorporating both touch-based rotation controls and precise programmatic rotation using Kotlin. This guide covers everything from basic rotation gestures to advanced group transformations and rotation constraints.
Key rotation features#
- Touch-based rotation with intuitive drag handles
- Precise angle control through Kotlin APIs
- Rotation locking for template protection
- Multi-element rotation as grouped objects
Touch-based image rotation#
Users can rotate images naturally using the built-in rotation handles. When you select an image:
- Rotation controls automatically appear.
- You can now freely rotate the image through drag gestures.

Implementing rotation in Kotlin#
Your Android app can control image rotation programmatically using the setRotation method. Pass the block ID and rotation angle in radians:
import kotlin.math.PI
engine.block.setRotation(imageBlock, (PI / 4).toFloat())Since Android developers often work with degrees, here are handy conversion utilities:
val angleInRadians: Float = (angleInDegrees * PI / 180).toFloat()
val angleInDegrees: Float = (angleInRadians * 180 / PI).toFloat()To read the current rotation state in your app:
val currentRotation = engine.block.getRotation(imageBlock)Locking Rotation#
You can remove the rotation handle from the UI by changing the setting for the engine. This will affect all blocks.
engine.editor.setSettingBoolean("controlGizmo/showRotateHandles", false)Although the code makes the rotation handle invisible, the user can still use the two-finger rotation gesture on a touch device. You can turn off that gesture with the following setting:
engine.editor.setSettingBoolean("touch/rotateAction", false)When you want to lock only certain blocks, you can toggle the transform lock property. This will apply to all transformations for the block.
engine.block.setTransformLocked(imageBlock, true)Rotating As a Group#
To rotate multiple elements together, first add them to a group and then rotate the group.
import kotlin.math.PI
val groupId = engine.block.group(listOf(imageBlock, textBlock))engine.block.setRotation(groupId, (PI / 2).toFloat())Troubleshooting#
Troubleshooting
| Issue | Solution |
|---|---|
| Image appears offset after rotation | Make sure the pivot point is centered (default is center). |
| Rotation not applying | Confirm that the image block is inserted and rendered before applying rotation. |
| Rotation handle not visible | Check that interactive UI controls are enabled in the settings. |