Dirk Hoffmann
03/07/2021, 11:04 AMColumn(modifier) {
TabRow(selectedTabIndex = activeTab()) {
Tab(selected = activeTab() == 0, onClick = { activeTab(0) }, enabled = true) {
Text("Tab 1", Modifier.padding(3.dp), textAlign = TextAlign.Center)
}
Tab(selected = activeTab() == 1, onClick = { activeTab(1) }, enabled = true) {
Text("Search: Result", Modifier.padding(3.dp), textAlign = TextAlign.Center)
}
Tab(selected = activeTab() == 2, onClick = { activeTab(2) }, enabled = true) {
Text("Tab 3", Modifier.padding(3.dp), textAlign = TextAlign.Center)
}
}
no matter what I try, I don't get the Tab Texts vertically centered.
Isn't TabRow missing a "verticalAligment" parameter???Glenn Martin
03/07/2021, 12:22 PMtop
padding and it did the trickIgor Demin
03/07/2021, 12:45 PMheight
and add fillMaxHeight()
to every Tab
Column {
TabRow(selectedTabIndex = 0, Modifier.height(48.dp)) {
Tab(selected = true, onClick = { }, enabled = true, modifier = Modifier.fillMaxHeight()) {
Text("Tab 1", Modifier.padding(3.dp), textAlign = TextAlign.Center)
}
Tab(selected = false, onClick = { }, enabled = true, modifier = Modifier.fillMaxHeight()) {
Text("Search: Result", Modifier.padding(3.dp), textAlign = TextAlign.Center)
}
Tab(selected = false, onClick = { }, enabled = true, modifier = Modifier.fillMaxHeight()) {
Text("Tab 3", Modifier.padding(3.dp), textAlign = TextAlign.Center)
}
}
}
If you need a dynamic height (height is determined by `TabRow`'s content), you should use something like this
CustomTabRow(selectedTabIndex = 0, Modifier.height(IntrinsicSize.Min))
Where CustomTabRow
is a copy of TabRow
, but without `SubcomposeLayout`(`SubcomposeLayout`doesn't support IntrinsicSize)Joe Jensen
03/19/2021, 4:24 PMSubcomposeLayout
ever support intrinsics ?Igor Demin
03/19/2021, 4:30 PMWillsee https://kotlinlang.slack.com/archives/CJLTWPH7S/p1606252338165700?thread_ts=1606251747.164900&cid=CJLTWPH7Sever support intrinsics ?SubcomposeLayout
Joe Jensen
03/19/2021, 4:32 PM