2017-08-29 96 views
0

这是很好的处理布局时,设备方向更改为横向或纵向的方法呢?阵营原生扩展样式景观

const common = { 
    container: { 
    flex: 1 
    } 
} 

// styles for portait orientation 
const portrait = StyleSheets.create({ 
    container: { 
    ...common.container, 
    marginBotton: 10 
    } 
}) 

// styles for landscape 
const landscape = StyleSheets.create({ 
    container: { 
    ...common.container, 
    flex: 0.5 
    } 
}) 

回答

0

为取向的问题,您可以使用尺寸,这需要的尺寸,并根据您的屏幕变化的风格。

import { Dimensions } from 'react-native'; 
const { width, height } = Dimensions.get('window') 

class SearchBox extends Component { 
render() { 
     return (
      <View style={styles.container}> 
       //yous codes here 
      </View> 
     ); 
    } 
} 

const styles = StyleSheet.create({ 
    container: { 
      width: width, 
     } 
}); 
+0

使用尺寸是指未正确使用柔性盒。我其实在谈论分裂风格。 –