'How to create a slide switch using jetpack compose?
Solution 1:[1]
You can use TabRow like this:
val items = (0..1)
var activeTabIndex by remember { mutableStateOf(0) }
TabRow(
selectedTabIndex = activeTabIndex, backgroundColor = Color.Transparent,
indicator = {
Box(
Modifier
.tabIndicatorOffset(it[activeTabIndex])
.fillMaxSize()
.background(color = Color.Cyan)
.zIndex(-1F)
)
},
) {
items.mapIndexed { i, item ->
Tab(selected = activeTabIndex == i, onClick = { activeTabIndex = i }) {
Icon(
painter = painterResource(id = someIcon),
contentDescription = null,
tint = Color.Black,
modifier = Modifier.padding(vertical = 20.dp)
)
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nesyou |

