Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

710
Visualizações
How to change pressed Tab color in TabRow in Android Jetpack Compose?

I have a simple Jetpack Compose TabRow example on Kotlin from documentation, where I just changed a text and underline color. But there is an orange background color when the tab is pressed. I want to make it transparent.

Image of TabRow

var state by remember { mutableStateOf(0) }
val titles = listOf("TOP", "NEW", "HOT")
Column {
    TabRow(
        contentColor = MaterialTheme.colors.primaryVariant, // This is underline's color
        selectedTabIndex = state
    ) {
        titles.forEachIndexed { index, title ->
            Tab(
                selectedContentColor = MaterialTheme.colors.primaryVariant,
                unselectedContentColor = MaterialTheme.colors.secondary,
                text = { Text(title) },
                selected = state == index,
                onClick = { state = index }
            )
        }
    }
    Text(
        modifier = Modifier.align(Alignment.CenterHorizontally),
        text = "Text tab ${state + 1} selected",
        style = MaterialTheme.typography.body1
    )
}
over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Right now, you can set backgroundColor for tabs like this:

TabRow(
   selectedTabIndex = state,
   ...
   backgroundColor = Color.White
)
over 4 years ago · Santiago Trujillo Relatório

0

If by pressed color, you are referring to this tab,

enter image description here

This is created by the Tab's ripple color.

This color would be affected by the selectedContentColor attribute in Tab.
But, even if you specify Transparent you would see a greyish ripple effect.

Modify the attribute to match with the closes satisfiable color as required.


The code creating the ripple effect.

// The color of the Ripple should always the selected color, as we want to show the color
// before the item is considered selected, and hence before the new contentColor is
// provided by TabTransition.
val ripple = rememberRipple(bounded = true, color = selectedContentColor)

As this is an internal implementation detail, we cannot disable it. ()

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda