https://kotlinlang.org logo
k

Kshitij Patil

02/16/2021, 4:26 PM
How can bring the cross button above the box? The Text & Icon are being defined inside a box which is managing stroke & background color as well as shape. I tried putting cross button in parent box and with zIndex of this child box less than the icon’s but didn’t work. Do I need to write custom layout for this?
d

Denis

02/16/2021, 4:30 PM
Code?
y

Yuri Drigin

02/16/2021, 5:42 PM
Box - alignment TopEnd, and Modifier. padding(4.dp) for the center shape
k

Kshitij Patil

02/16/2021, 5:54 PM
d

Denis

02/16/2021, 6:00 PM
@Kshitij Patil, I tried to insert your code like
Copy code
@Preview
@Composable
fun CrossButtonPreview() {
    /* Your code */
}
but there were too many errors. It would be nice to have a self-contained example, so we can collaborate easily. Have you solved the problem?
a

Afzal Najam

02/16/2021, 6:27 PM
Instead of putting the icon in the box with the border, you could use a container and make them siblings inside it
s

Shakil Karim

02/16/2021, 7:27 PM
Try offset
k

Kshitij Patil

02/16/2021, 7:28 PM
@Denis will share a self contained example tomorrow, I was in bit hurry so just shared a snippet that's responsible for Box & Icon. @Afzal Najam I tried that way but how can I know the dimensions of box so that I can correctly place the icon on it's topRight edge.
👍 1
@Shakil Karim I've already used that in the snippet I shared
Surprisingly, when I wrote them in a separate Composable and doing as @ Afzal Najam mentioned, it just worked. Here is a snippet for that.
❤️ 1
🎉 2
3 Views