相关疑难解决方法(0)

是否可以将Image.getSize与静态图像文件一起使用?

我想使用Image.getSize(https://facebook.github.io/react-native/docs/image.html)来获取我的图像的大小,但第一个参数要求图像源在URI中,但我可以不要将URI与静态文件一起使用,我只能使用Require.

因此,是否可以在静态文件上使用Image.getSize或者我必须找到另一种方法?

image static-files react-native

16
推荐指数
3
解决办法
8413
查看次数

如何在React Native中以16:9的比例设置视图样式?

我想让红色视图保持16:9的比例。我尝试但失败了。我知道React Native使用Flexbox(用Java重新实现),但是我不知道该怎么做。谢谢。

这是我的Javascript:

'use strict';

var React = require('react-native');
var {
  AppRegistry,
  StyleSheet,
  View,
} = React;

var AwesomeProject = React.createClass({
  render: function() {
    return (
      <View style={styles.container}>
        <View style={styles.banner}>

        </View>
        <View style={styles.items}>

        </View>
      </View>
    );
  }
});

var styles = StyleSheet.create({
  container: {
    flex: 1,
  },
  banner: {
    backgroundColor: 'red',
    flex: 1,
  },
  items: {
    backgroundColor: 'blue',
    flex: 3,
  },
});

AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);
Run Code Online (Sandbox Code Playgroud)

这是关于React Native中Flexbox的文档:

http://facebook.github.io/react-native/docs/flexbox.html#content

这是有效的样式道具:

Valid style props: [
  "width",
  "height",
  "top",
  "left",
  "right",
  "bottom", …
Run Code Online (Sandbox Code Playgroud)

facebook ios flexbox reactjs react-native

3
推荐指数
1
解决办法
1718
查看次数

React Native Aspect适合图像

    <Image
      style={{
        alignSelf: 'center',
        flex: 1,
        width: '25%',
        height: null,
        resizeMode: 'cover',
        borderWidth: 1,
        borderRadius: 75,
      }}
      source={{uri:'https://facebook.github.io/react/img/logo_og.png'}}
      resizeMode="stretch"
    />
Run Code Online (Sandbox Code Playgroud)

https://snack.expo.io/rJCoC9S5-

我如何将图像宽度设为父级的25%,并将其高度设置为保持原始的width:height纵横比所需的高度?

react-native

2
推荐指数
1
解决办法
2964
查看次数

标签 统计

react-native ×3

facebook ×1

flexbox ×1

image ×1

ios ×1

reactjs ×1

static-files ×1