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

190
Views
React Native - Adapt image size to layout

OBJECTIVE

I need to achieve this layout:

Simple grid layout

PROBLEM

As I don't need any infinite scrolling, I have make it simple.

The boxes will be covered with images.

The main problem I am facing is that I don't know how to adapt all these images dimensions to the users device (and the layout too).

CODE

Check my snack to emulate the code.

Here is my current code:

import React from 'react';
import { View, Image, StyleSheet } from 'react-native';
import Constants from 'expo-constants';

const BANNER_DIMENSIONS = {
  width: 1200,
  height: 600,
};

const SQUARE_DIMENSIONS = {
  width: 1080,
  height: 1080,
};

const PORTRAIT_DIMENSIONS = {
  width: 1080,
  height: 1350,
};

const POSTER_DIMENSIONS = {
  width: 1080,
  height: 1920,
};

const URIS = {
  banner:
    'https://thumbs.dreamstime.com/b/retrato-de-adolf-hitler-pintado-por-b-jackobs-imagen-del-libro-bilder-aus-dem-leben-des-fuhrers-im%C3%A1genes-la-vida-fuhrer-publicado-183308284.jpg',
  square:
    'https://fotos.perfil.com/2021/04/27/trim/950/534/benito-mussolini-1164371.jpg',
  portrait:
    'https://zeleb.publico.es/sites/default/files/styles/news_main_image_amp/public/franco2_0.jpg?itok=3Ve-RxCd',
  poster: 'https://m.media-amazon.com/images/I/41dLCrwvZFL.jpg',
};

export default function App() {
  return (
    <View style={styles.container}>
      <View style={styles.row}>
        <View>
          <View style={styles.imageContainer}>
            <Image source={URIS.banner} style={styles.banner} />
          </View>

          <View style={styles.row}>
            <View style={styles.imageContainer}>
              <Image source={URIS.square} style={styles.square} />
            </View>

            <View style={styles.imageContainer}>
              <Image source={URIS.portrait} style={styles.portrait} />
            </View>
          </View>
        </View>

        <View style={styles.imageContainer}>
          <Image source={URIS.poster} style={styles.poster} />
        </View>
      </View>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    paddingTop: Constants.statusBarHeight,
    backgroundColor: '#ecf0f1',
  },
  row: {
    flexDirection: 'row',
  },
  imageContainer: {
    paddingLeft: 10,
    paddingTop: 10,
  },
  banner: {
    ...BANNER_DIMENSIONS,
  },
  square: {
    ...SQUARE_DIMENSIONS,
  },
  portrait: {
    ...PORTRAIT_DIMENSIONS,
  },
  poster: {
    ...POSTER_DIMENSIONS,
  },
});
about 4 years ago · Juan Pablo Isaza
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!