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

173
Vistas
How do you scale a ScrollView / View smaller but still have it take up the entire with and height of the screen?

I'm working on a game with my brother. It's not meant to be fancy or anything so don't laugh at the very poor graphics. We've created a map with a grass background and a "Mining Area" that is meant for you to be able to tap on and go inside the "Mine".

The problem that I'm having is when scaling the Scroll View down ( scale set to 0.6) I'm left with huge amount of black border surrounding it. I want the Scroll View to take up the space that the black border around the Scroll View is leaving.

Scale Problem

The center of the image is the Scroll View. I want the Scroll View to take the black space surrounding it.

I've tried setting the Scroll View Width and Height to 100%... This does not make a difference. Setting the Width manually with pixels will change the Width and Height but then your using positioning absolute and moving the images to the top left which left: 0 and top: 0 does not move it to the top nor does left move it to the left and at that point it becomes a guessing game with the different screen sizes. I've tried using React Native Dimensions, and this has the same effect as setting the Width and Height to 100%.

Here is what I have so far...

import React, { useContext } from "react";
import styled from "styled-components/native";
import Context from "../store/player-context";
import BottomNavigationBar from "../Game-Components/BottomNavigationBar";
import TopGameBar from "../Game-Components/TopGameBar";
import { StatusBar } from "expo-status-bar";
import MineShaftPOI from "../Game-Components/POI/MineShaftPOI";
import { Dimensions } from "react-native";

const Game = () => {
const ctx = useContext(Context);

const handleScroll = (event) => {
const posX = Math.ceil(event.nativeEvent.contentOffset.x);
const poxY = Math.ceil(event.nativeEvent.contentOffset.y);

ctx.setScrollXY({ x: posX, y: poxY });
};

return (
<Wrapper>
  <StatusBar style="light" />
  <TopGameBar />
  <BackGroundContainer
    horizontal={true}
    scrollEnabled={ctx.scroll}
    bounces={false}
    onScroll={handleScroll}
  >
    <GrassBackGround
      source={require("../assets/images/grassMap.png")}
      resizeMode="stretch"
      transition={false}
      style={{ aspectRatio: 3 / 2 }}
    />
    <MineShaftPOI />
  </BackGroundContainer>
  <BottomNavigationBar />
</Wrapper>
);
};

const BackGroundContainer = styled.ScrollView`
transform: scale(0.6);
width: 100%;
height: 100%;
`;

 const GrassBackGround = styled.Image``;

 const Wrapper = styled.View`
 width: 100%;
 padding: 0;
 margin: 0;
 flex: 1;
 background-color: #111111;
 `;

export default Game;

Has anyone else came up with a solution for this?

Edit: I forgot to mention I'm using styled-components if anyone was wondering.

Thanks

about 4 years ago · Juan Pablo Isaza
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