[SOLVED] How to have dashed border in Jetpack Compose?

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under
CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.


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

src=”https://i.stack.imgur.com/LAgGW.png” alt=”enter image description here” />


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.


Answered By – David Ibrahim

people found this article helpful. What about you?