Appearance and animation
| This documentation was generated with the assistance of AI. Please report any inaccuracies. |
Margins and background
Pages are laid out inside the view, minus its margins. Margins can be set in pixels, or proportionally to the view
size. The background (OpenGL clear color) is drawn around the pages, and is transparent by default, so views behind
CurlTextureView remain visible:
// Margins in pixels
curlView.setMargins(32, 32, 32, 32)
// Proportional margins: 0.1f is 10% of the view width (left/right) or height (top/bottom)
curlView.setProportionalMargins(0.1f, 0.1f, 0.1f, 0.1f)
// OpenGL clear color, drawn around the pages. Transparent by default.
curlView.setBackgroundColor(Color.TRANSPARENT)
Proportional margins are fractions of the view width (left and right) and height (top and bottom). To derive them
from sizes in pixels or dp, compute them in a SizeChangedObserver, as shown in
Reacting to size changes.
Shadows and curl mesh
Each page is a mesh of polygons that is split along the curl. Shadows are drawn under the curl (drop shadow) and on the curled page itself (self shadow), and the area of the texture close to the curl is darkened.
// Mesh properties can only be changed while no page provider is set
// (they throw IllegalArgumentException otherwise), so configure them first.
curlView.maxCurlSplitsInMesh = 20 // smoother curl, more polygons
curlView.drawShadowInMesh = true
curlView.shadowInnerColorInMesh = floatArrayOf(0.0f, 0.0f, 0.0f, 0.6f) // RGBA in [0, 1]
curlView.shadowOuterColorInMesh = floatArrayOf(0.0f, 0.0f, 0.0f, 0.0f)
curlView.colorFactorOffsetInMesh = 0.5f // lighter area close to the curl
curlView.pageProvider = pageProvider
| Property | Effect |
|---|---|
|
Maximum number of times the curl is split. Larger values give a smoother curl with more polygons. Default |
|
Enables shadow rendering. Default |
|
RGBA color (4 values in |
|
RGBA color (4 values in |
|
Brightness of the texture close to the curl, in |
The mesh properties (maxCurlSplitsInMesh and every …InMesh property) can only be changed while
pageProvider is null, and throw IllegalArgumentException otherwise. Set them before the page provider.
|
Animation
// Duration of the animation that completes (or reverts) a flip when the finger is raised
curlView.animationDurationTime = 300
// Duration of each page flip when jumping with setSmoothCurrentIndex
curlView.pageJumpDurationTime = 500L
// Use touch pressure to change the curl radius (experimental, device dependent)
curlView.enableTouchPressure = true
-
animationDurationTime: duration, in milliseconds, of the animation that completes or reverts a flip when the finger is raised. Default300. -
pageJumpDurationTime: duration, in milliseconds, of the flip animated bysetSmoothCurrentIndex. Default500. -
enableTouchPressure: uses touch pressure to change the curl radius (the harder you press, the flatter the curl). Experimental: results vary between devices, and emulators report a constant pressure. Defaultfalse.
Development aids
// Development aids: show how each page is split into polygons and where the curl is
curlView.drawPolygonOutlinesInMesh = true
curlView.drawCurlPositionInMesh = true
curlView.drawTextureInMesh = false
drawPolygonOutlinesInMesh shows how each page is divided into polygons, drawCurlPositionInMesh draws the curl
position and direction, and drawTextureInMesh = false hides the page textures. Like every mesh property, they must be
set while pageProvider is null.
Next: Configuration reference.