Search code examples
androidborderandroid-jetpack-compose

How to have dashed border in Jetpack Compose?


I can easily create a normal border using the Modifier.border() but how to create a dashed border as shown in the image below.

enter image description here


Solution

  • After some digging in the normal border modifier, I found out that it uses Stroke object which can take a parameter PathEffect that can make it dashed, here is a modified version of the normal border function that takes this parameter.

    https://gist.github.com/DavidIbrahim/236dadbccd99c4fd328e53587df35a21