hi everyone, i creating a grid system like the ima...
# compose
m
hi everyone, i creating a grid system like the image and want to make an animation by translating the red circle into specific circle cell in the grid. im using
animateDpAsState
to make the animation and it works however the offset seems a little bit off the place when going to the last circle cell. When i zooming in the preview, i saw these layout indicator line.
and it has a little space between the second and third line ( as well as sixth and seventh ) is it the problem why my red circle is off the place ?
c
Do you have a code snippet?
On the preview grey lines, I think that might be a fault on our end for how we are drawing them when things overlap. Would be good to see a video also of where things look off
m
im implementing it using 2 loops with column and row
Copy code
Column {
       Row {
            Rectangle()
       }
}
like this
will it be the problem of dp ?
Copy code
Box(modifier = Modifier
    .offset(x = offsetXState.value.dp, y = offsetYState.value.dp)
    .size(cellSize.dp)
    .aspectRatio(1f)
    .background(Color(0xFFf75f57))
)
since im offseting that red circle with modifier
offset
and it is using dp
d
It may be due to the rounding with Dp. Have you tried operating on pixel instead, with the
Copy code
fun Modifier.offset(offset: Density.() -> IntOffset)
API instead? I'd recommend this API for animations since it avoids recomposition on every frame which is more efficient