【发布时间】:2020-06-27 12:55:14
【问题描述】:
我的代码:
import React, { PureComponent } from 'react'
import { StyleSheet, View } from 'react-native'
import {
isPortrait
} from './Constants'
export default class TwoVideoView extends PureComponent {
render() {
return (
<View style={styles.conatiner}>
<View style={[styles.videoHalfView, {backgroundColor: 'white'}]}>
</View>
<View style={[styles.videoHalfView, {backgroundColor: 'gray'}]}>
</View>
</View>
)
}
}
const styles = StyleSheet.create({
conatiner: {
flex: 1,
backgroundColor: 'red',
flexDirection: isPortrait ? ('column') : ('row')
},
videoFullView: {
width: '100%',
height: '100%'
},
videoHalfView: {
width: isPortrait ? ('100%') : ('50%'),
height: isPortrait ? ('50%') : ('100%')
}
})
人像输出:
您能帮我完成这项工作吗?
我尝试添加Dimensions.addListener('change') 没有奏效 我只想更新 My View 渲染而不是其他 Api Stuff。
我要换flexDirection: isPortrait ? ('column') : ('row')
export const isPortrait = () => {
const dim = Dimensions.get('screen');
return dim.height >= dim.width;
};
【问题讨论】:
标签: android ios reactjs react-native