zl程序教程

您现在的位置是:首页 >  其它

当前栏目

[Flexbox] Use Flex to Scale Background Image

to use Image flex background scale Flexbox
2023-09-14 09:00:53 时间

In this lesson we will use Flexbox to scale a background image to fit on the screen of our React Native application.

 

import React, { Component } from 'react';
import {AppRegistry, StyleSheet, Text, View, Image} from 'react-native';

export default class general extends Component {
  render() {
    return (
      <Image source={require("./cat.jpg")} style={styles.container}>
        <Text>A good looking cat</Text>
      </Image>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    width: null,
    height: null,
    alignItems: "center",
    justifyContent: "center"
  }
})

AppRegistry.registerComponent('general', () => general);