I want to draw a rectangle on every composable in ...
# compose
a
I want to draw a rectangle on every composable in the hierarchy for debugging purposes, but i dont know how to start with this. Is there any way to either draw on all composables or maybe get the bounds of every composable in the hierarchy?
c
My first idea would be a Modifier.
s
Compose already has support for 'Show Layout Bounds' in the Android Developer Settings, which you can utilize. If you need to draw a specific rectangle, you can do so by using
Modifier.drawWithContent
or
Modifier.drawBehind
. However, you will need to apply it manually where you want to visualize the bounds.
a
@Sergey Y. im not on android
👀 1
a
@Chrimaeon any specific apis to get the bounds of every child? im not familiar with custom modifiers
s
AFAIK, there are no API for that.
s
I've finally found it. Square has a similar library which you can find at https://github.com/square/radiography. I'm not sure if it supports multiplatform, but you can check how they read the widget hierarchy.
👍 1