ShapeMorphView — ShapeMorphView is a simple library for smooth morphing between different Material 3 Expressive Shapes.
- Smooth morphing between different shapes
- Image change with morph animation
- Customizable animation duration
The project includes a simple app. You might find it useful.
Add the dependency to your build.gradle.kts:
dependencies {
implementation("io.github.dertefter:shapemorphview:0.0.3")
}Add ShapeMorphView to your layout:
<com.dertefter.shapemorphview.ShapeMorphView
android:id="@+id/smv"
app:animationDuration="500"
app:bgColor="?attr/colorPrimaryContainer"
app:imageResource="@drawable/your_drawable"
app:shape="SLANTED_SQUARE" />animationDuration- duration of the shape morphing animation in millisecondsbgColor- background fill color of the shapeimageResource- allows setting an imageshape- allows setting the shape
The library supports 35 Material 3 Expressive shapes:
CIRCLE, SQUARE, SLANTED_SQUARE, ARCH, FAN, ARROW, SEMI_CIRCLE, OVAL, PILL, TRIANGLE, DIAMOND, CLAM_SHELL, PENTAGON, GEM, SUNNY, VERY_SUNNY, COOKIE_4, COOKIE_6, COOKIE_7, COOKIE_9, COOKIE_12, GHOSTISH, CLOVER_4, CLOVER_8, BURST, SOFT_BURST, BOOM, SOFT_BOOM, FLOWER, PUFFY, PUFFY_DIAMOND, PIXEL_CIRCLE, PIXEL_TRIANGLE, BUN, HEART
You can change the shape using morphToShape.
To set a specific shape, use the following:
shapeMorphView.morphToShape(
newShape = Shape.ARCH,
animate = true // with or without animation, defaults to true
)The shape can be selected from com.dertefter.shapemorphview.Shape
To set a random shape, use the following:
shapeMorphView.morphToShape(
newShape = shapeMorphView.getRandomShape(),
animate = true
)You can set the animation speed programmatically:
shapeMorphView.animationDuration = 500You can change the image and morph to a shape like this:
shapeMorphView.setDrawableResId(
resId = R.drawable.your_drawable,
newShape = shapeMorphView.getRandomShape(),
animate = true
)This library is distributed under the MIT license.
See LICENSE for details.


