Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

310
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!