Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

304
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda