Search code examples
android-jetpack-composeandroid-jetpackandroid-jetpack-compose-material3android-jetpack-compose-canvas

How to crop specific areas of a container while preserving the shadow underneath in Jetpack Compose?


I have a container (Card, Box, or whatever..) that contains two problematic areas, marked with red circles. I need to crop these areas out while ensuring that the shadow underneath is preserved.

enter image description here

I have tried different approaches, but I couldn't find a solution to crop the areas effectively.


Solution

  • Use the .border(width = ..., color = .., CustomShape(...)) modifier with a custom shape. Here is a detailed explanation Custom Shape with Jetpack Compose

    The result:

    enter image description here