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

306
Visualizações
React Native: How to wrap content the height of Scrollview?

I'm trying to create a filter button. I need the Scrollview because the categories comes from an API and it wouldn't fit in a single screen size. I need the height to wrap content because the Scrollview is horozontal but it did not work when I used alignSelf:'baseline'. I could wrap the ScrollView around a View but the button height is not static.

This is how the screen looks like:

enter image description here

<ScrollView 
    showsHorizontalScrollIndicator={false} 
    horizontal={true} 
    style={[GlobalStyle.ListTab]}>
    {listTab.map(item => (
        <TouchableOpacity key={item.id} 
            activeOpacity={0.8} 
            onPress={() => setStatusFilter(item.name)} 
            style={[GlobalStyle.ButtonTab, status === item.name && GlobalStyle.ActiveButtonTab]}> 
            <Text style={[GlobalStyle.TextTab]}>{item.name}</Text>
        </TouchableOpacity>
    ))}
</ScrollView>

GlobalStyle.js

ListTab: {
    alignSelf:'baseline',
    marginBottom: 20,
    backgroundColor: red,
},
ButtonTab: {
    minWidth: DEVICE_WIDTH / 3.6,
    flexDirection: 'row',
    padding: 10,
    justifyContent: 'center', 
    backgroundColor: white,
    marginHorizontal: 10, 
    elevation: 10,
    alignSelf:'baseline', 
},
TextTab: {
    fontSize: 16,
    alignSelf:'baseline', 
},
ActiveButtonTab: {
    backgroundColor: purple,
},
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Here, you can achieve output using the following way:

  • Wrap ScrollView in another View and give height to that View
  • Using flexGrow for ScrollView style
ListTab: {
    flexGrow: 0,   //<---- here
    alignSelf:'baseline',
    marginBottom: 20,
    backgroundColor: red,
},
about 4 years ago · Juan Pablo Isaza 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