Skip to content

Image as background cannot set background position #12347

Description

@sscaff1

I have a variable image coming from the web that I need to use as the background of a container. So this works fine. The only problem is I don't know how to set the position of the background. I want to use something like background-position so that my background is in the top left.

Here is a code snippet:

export default function App({ uri }) {
  return (
    <Image source={{ uri }} style={styles.container}>
      <Text>HELLO WORLD</Text>
    </Image>
  );
}
const styles = StyleSheet.create({
  container: {
    padding: 5,
    height: 150,
    width: WINDOW_WIDTH,
    resizeMode: 'cover',
    backgroundColor: 'transparent',
  },
});

The default background position seems to be the center of the image. Anyway to get this to work?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions