Search code examples
androidkotlintextandroid-jetpack-composepadding

How to remove spacing Text is adding in Jetpack Compose


I'm trying to make a bar graph, that has labels on some of them. Image of the bar as is right now. The labels below each vertical bar is adding unwanted spacing between the bars. I would like the remove that extra spacing between each bar, but I don't know how. I made the bars with Jetpack Compose, like this (I removed most of the code. It isn't necessary to show in this case):

Column(
    modifier = Modifier
        .width(8.dp)
) {
    Column(
        modifier = modifier
    ) {
        Box(
            modifier = Modifier
        )
        Box(
            modifier = Modifier
        )

    }
    vText(
        text = "21",
        modifier = Modifier,
    )
}

I added the bars in a Row().

I need a solution as to how I can make the space between each bar the same, but still be able to show the labels. I tried SpaceEvenly in the Row(), but that just cuts off the label.


Solution

  • I found a solution. I edited the Text() to include the modifier .wrapContentSize(unbounded = true).

    Image of the result