androidkotlinuser-interfaceandroid-jetpack-compose

How do I remove unnecessary space in a Row in Android?


I have added Button inside a Row. There is a unnecessary vertical padding in Row. When I make Button fillMaxHeight() then this area got filled. I want to wrap the button without that space. And this is the compose preview. Please help. code snippet and preview of the problem

Row { // There is not vertical padding added
    OutlinedButton(onClick = {}) {
        Text("Button")
    }
}

I have set padding of Row to 0dp. And vertically Aligned to top but it's the same.


Solution

  • It is actually caused by LocalMinimumInteractiveComponentSize as mentioned by @tyg. This is fixed Using CompositionLocalProvider.

    CompositionLocalProvider(LocalMinimumInteractiveComponentSize provides Dp.Unspecified) {
        Row {
            OutlinedButton(onClick = {}) {
                Text("Button")
           }
        }
    }
    

    Answer found here (depricated)