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

133
Views
Setting width of container returns unexpected result

I have a container <View style={styles.container}> in which is a <FlatList />. An element rendered by the <FlatList /> is a card, styled like this

  card: {
    borderColor: 'green',
    borderWidth: 2,
    borderTopRightRadius: 7,
    borderBottomRightRadius: 7,
    borderBottomLeftRadius: 7,
    backgroundColor: 'white',
    padding: 5,
    width: '100%',
    height: 290,
  },

There is snack here https://snack.expo.dev/90GJaJuPw

Now, there are two problems.

  1. Why is <View style={styles.thisAffectsCardWidth} /> not horizontally in the center of the card?
  2. Why is the the width of the card <View style={styles.card} /> getting larger, when one adjusts the width of thisAffectsCardWidth from e.g. 50% to 100%`?
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

  1. Try removing alignItems: 'center' from the contentContainerStyle and add width: '100%' Eg: contentContainerStyle={{ width: '100%' }} and add alignItems: 'center' to the card styles.

https://snack.expo.dev/@charinda04/forlorn-cereal

  1. Since you haven't set the contentContainerStyle width of the flatList, Width changes with thisAffectsCardWidth width.
about 4 years ago · Santiago Trujillo 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!