Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom TabRow in Jetpack Compose

I use TabRow and I have two questions:

  • Is it possible to remove a line that is wide the entire width screen?

  • How Can I bring the buttons together (reduce space between them)

enter image description here

like image 428
Wafi_ck Avatar asked Nov 01 '25 09:11

Wafi_ck


1 Answers

To remove the line under the tabs just set an empty divider by passing divider = {}.

To make the tabs fill the space available in the TabRow (therefore without empty spaces), just do not set a specific size to the Tabs, the following example works as you ask.

var state by remember { mutableStateOf(0) }
val titles = listOf("TAB 1", "TAB 2")
Column {
    TabRow(selectedTabIndex = state, divider = {}) {
        titles.forEachIndexed { index, title ->
            Tab(
                text = { Text(title) },
                selected = state == index,
                onClick = { state = index }
            )
        }
    }
}
like image 195
Stefano Sansone Avatar answered Nov 03 '25 23:11

Stefano Sansone



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!