https://kotlinlang.org logo
#compose
Title
# compose
m

Mihai Hrincescu

10/20/2020, 8:45 PM
Hello everyone I've encountered some weird behaviour with
.clickable()
modifier when i scale up a
@composable
using
.drawLayer()
the hit box not only it does not scale up but it actually scales down and moves down and to the right proportionate to where the the
@composable
is placed inside of the available space. Should i just change the size instead or is this just a bug and scaling a
@composable
should also scale the hit box?
Copy code
@Composable
fun testScale() {
    Box(
        modifier = Modifier.fillMaxSize(),
        alignment = Alignment.Center
    ) {
        var selected by remember { mutableStateOf(false) }
        val scale = if (selected) 2f else 1f

        Box(
            modifier = Modifier
                .size(64.dp)
                .drawLayer(scaleX = scale, scaleY = scale)
                .background(Color.Green)
                .clickable(
                    onClick = { selected = !selected },
                    indication = null
                )
        ) {
            Text(
                modifier = Modifier.align(Alignment.Center),
                textAlign = TextAlign.Center,
                text = "Button"
            )
        }
    }
}
z

Zach Klippenstein (he/him) [MOD]

10/20/2020, 9:04 PM
sounds like a bug to me. i’d file it
m

Mihai Hrincescu

10/20/2020, 9:12 PM
I was thinking that maybe i miss use the api because i scale using the draw layer and do not touch the layout. Thanks @Zach Klippenstein (he/him) [MOD] i will file it.
z

Zach Klippenstein (he/him) [MOD]

10/20/2020, 9:15 PM
From previous discussions, i believe
drawLayer
is intended to affect input events as well. I would definitely not expect it to affect input events in the opposite direction.
m

Mihai Hrincescu

10/20/2020, 9:22 PM
So the API should work as i thought it would. That means that it's definitely a bug.
z

Zach Klippenstein (he/him) [MOD]

10/20/2020, 9:23 PM
I think it should. File it anyway - if it's not a bug, it's a signal that the docs aren't clear
2 Views