I simply want to offset an Image always the exact amount no matter what screen resolution the user has.
I tried it like this:
var heightIs by remember { mutableStateOf(0f) }
Box(
modifier = Modifier
.fillMaxSize()
.aspectRatio(
ratio = 1f
).onGloballyPositioned { coordinates ->
heightIs = (coordinates.size.height.toFloat())
}
) {
Image(
painter = painterResource(id = R.drawable.base),
contentDescription = "Shadow",
modifier = Modifier.fillMaxSize()
)
Image(
painter = painterResource(id = R.drawable.top_mask_normal),
contentDescription = "Shadow Stencil",
colorFilter = ColorFilter.tint(color, BlendMode.SrcAtop),
modifier = Modifier
.fillMaxSize()
.offset(y = ((heightIs * 0.03).toInt()).dp)
)
}
But I get different results on different screen resolutions. I want it exactly at the same position every time not matter if the user uses a tablet or a 480x800 device