Skip to content

kseniianam/samples

Repository files navigation

Samples

Neumorphism

Researching if it possible to create Neumorphic UI with out-of-the-box functionality of Jetpack Compose

Idea

In Neumorphism objects appear to extrude from the background. This effect can be reached by drawing two shadows on the top left and bottom right. The shadows should spread smoothly.

Smooth shadow spreading can be implemented in two ways:

  1. Gradient shadow
  2. Blurred shadow

Research results

I've implemented sample UI via Jetpack Compose. There is a button NeumorphButton, which listens users actions with pointerInteropFilter. Action events change the button's state ButtonState.

Most challenging issue is to implement shadows smooth spreading.

  1. I've created button with RadialGradient, like here. The problem is, that this gradient only for circles, and there is no such out-of-the-box gradients for rounded rectangles.

  2. There is a lib neumorphic-compose with blurred shadows. It uses RenderScript which API will be deprecated starting with Android 12 and lib's author plans a migration. Google recommends migrate to Vulkan.

  3. Blur feature was also requested in JetpackCompose by developers. You can use it since 1.1.0-alpha03 Compose version, anyway it's only supported for Android 12 and above. Attempts to use this Modifier on older Android versions will be ignored. There is a doc.

Useful links

Releases

No releases published

Packages

No packages published

Languages