本文主要講解與flex布局相關(guān)的屬性保檐,包括flex耕蝉,flexDirection,alignItems夜只,justifyContent垒在,flexWrap等。React Native其他所有屬性均在LayoutPropTypes.js中定義,在編輯器中搜索LayoutPropTypes.js即可看到场躯。文末附所有測試代碼谈为。
首先定義幾個樣式,這樣在視圖中能更好的看到測試效果:
const styles = StyleSheet.create({
// 父容器樣式
container: {
borderWidth:1,
padding:5,
margin:5,
},
// 文字標簽樣式
label: {
color:'#333333',
margin:5,
},
});
flexDirection
子元素在父容器中的排列方向:
flexDirection:'row'
, 水平排列
flexDirection:'column'
, 垂直排列
子元素排列方向舉例
1.默認情況下父容器flexDirection:'column'
踢关,子元素從上到下垂直排列:
<Text style={styles.label}>默認情況下父容器flexDirection:'column'伞鲫,子元素從上到下垂直排列</Text>
<View style={[{},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
</View>
視圖:
2.父容器flexDirection:'column'
,子元素從左到右水平排列:
<Text style={styles.label}>父容器flexDirection:'column'签舞,子元素從左到右水平排列</Text>
<View style={[styles.container,{flexDirection:'row'}]}>
<Text>測試</Text>
<Text>測試</Text>
<Text>測試</Text>
</View>
視圖:
3.父容器flexDirection:'column'
秕脓,子元素從上到下垂直排列,與默認情況父容器不設置flexDirection相同:
<Text style={styles.label}>父容器flexDirection:'column'儒搭,子元素從上到下垂直排列吠架,與默認情況父容器不設置flexDirection相同</Text>
<View style={[{flexDirection:'column',},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
<Text>測試</Text>
</View>
視圖:
flex
類似于Android中權(quán)重layout_weight
的概念,需要配合flexDirection
使用才有效果。
舉例
1.父容器默認情況下(flexDirection:'column'
)子元素從上到下垂直排列搂鲫,此時子元素默認水平方向填充父容器;子元素flex:1
,在垂直方向起作用傍药,表示垂直方向占滿父容器空間:
<View style={[styles.container,{height:80}]}>
<View style={{backgroundColor:'red',flex:1}}/>
<View style={{height:20,backgroundColor:'green'}/>
</View>
視圖:
2.父容器flexDirection:'row'
時子元素從左到右水平排列;flex:1
在水平方向起作用,表示水平方向占滿全部父容器空間:
<Text style={styles.label}>父容器flexDirection:'row'時子元素從左到右水平排列;flex:1在水平方向起作用魂仍,表示水平方向占滿全部父容器空間</Text>
<View style={[{height:60,flexDirection:'row'},styles.container]}>
<View style={{height:20,flex:1,backgroundColor:'red'}}></View>
<View style={{height:20,width:100,backgroundColor:'green',}}></View>
</View>
視圖:
3.父容器flexDirection:'column'
拐辽,只有一個子元素;子元素flex:1
,占滿全部父容器空間,子元素height
不起作用:
<Text style={styles.label}>父容器flexDirection:'column'擦酌,只有一個子元素;子元素flex:1,占滿全部父容器空間俱诸,子元素height不起作用</Text>
<View style={[{height:100,flexDirection:'column'},styles.container]}>
<View style={{flex:1,backgroundColor:'red',height:10,}}></View>
</View>
視圖:
4.父容器flexDirection:'row'
,只有一個子元素;子元素flex:1
,占滿全部父容器空間,子元素width
不起作用:
<Text style={styles.label}>父容器flexDirection:'row'赊舶,只有一個子元素;子元素flex:1,占滿全部父容器空間,子元素width不起作用</Text>
<View style={[{height:100,flexDirection:'row'},styles.container]}>
<View style={{flex:1,backgroundColor:'red',width:10}}/>
</View>
視圖:
5.父容器flexDirection:'row'
乙埃,子元素在水平方向按比例分配父容器空間:
<Text style={styles.label}>父容器flexDirection:'row',子元素在水平方向按比例分配父容器空間</Text>
<View style={[{height:40,flexDirection:'row'},styles.container]}>
<View style={{flex:1,backgroundColor:'red',height:20}}/>
<View style={{flex:2,backgroundColor:'green',height:20}}/>
</View>
視圖:
6.父容器flexDirection:'column'
锯岖,子元素在垂直方向按比例分配父容器空間:
<Text style={styles.label}>父容器flexDirection:'column',子元素在垂直方向按比例分配父容器空間</Text>
<View style={[{height:100,flexDirection:'column'},styles.container]}>
<View style={{flex:1,backgroundColor:'red',width:20}}/>
<View style={{flex:1,backgroundColor:'green',width:20}}/>
</View>
視圖:
justifyContent
表示在水平方向或垂直方向子元素的對齊方式甫何,需要配合flexDirection
使用出吹。
當父容器flexDirection:'row'時
justifyContent:'flex-start'
,表示子元素水平方向左對齊
justifyContent:'center'
辙喂,表示子元素水平居中對齊
justifyContent:'flex-end'
捶牢,表示子元素水平方向右對齊
justifyContent:'space-between'
,表示子元素水平方向元素之間間隔相同
justifyContent:'space-around'
巍耗,表示子元素水平方向元素兩邊間隔相同
當父容器flexDirection:'column'時
justifyContent:'flex-start'
秋麸,表示子元素垂直方向上對齊
justifyContent:'center'
,表示子元素垂直居下對齊
justifyContent:'flex-end'
炬太,表示子元素垂直方向居中對齊
justifyContent:'space-between'
灸蟆,表示垂直方向子元素之間間隔相同
justifyContent:'space-around'
,表示垂直方向子元素兩邊間隔相同
水平方向即flexDirection:'row'時舉例
1.水平方向左對齊亲族,justifyContent:'flex-start'
:
<Text style={styles.label}>水平方向左對齊炒考,justifyContent:'flex-start'</Text>
<View style={[{flexDirection:'row',justifyContent:'flex-start'},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
<Text>測試</Text>
</View>
視圖:
2.水平方向居中對齊可缚,justifyContent:'center'
:
<Text style={styles.label}>水平方向居中對齊,justifyContent:'center'</Text>
<View style={[{flexDirection:'row',justifyContent:'center'},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
<Text>測試</Text>
</View>
視圖:
3.水平方向右對齊斋枢,justifyContent:'flex-end'
:
<Text style={styles.label}>水平方向右對齊帘靡,justifyContent:'flex-end'</Text>
<View style={[{flexDirection:'row',justifyContent:'flex-end'},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
<Text>測試</Text>
</View>
視圖:
4.水平方向元素之間間隔相同,justifyContent:'space-between'
:
<Text style={styles.label}>水平方向元素之間間隔相同瓤帚,justifyContent:'space-between'</Text>
<View style={[{flexDirection:'row',justifyContent:'space-between'},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
<Text>測試</Text>
</View>
視圖:
5.水平方向元素兩邊間隔相同描姚,justifyContent:'space-around'
:
<Text style={styles.label}>水平方向元素兩邊間隔相同,justifyContent:'space-around'</Text>
<View style={[{flexDirection:'row',justifyContent:'space-around'},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
<Text>測試</Text>
</View>
視圖:
垂直方向即flexDirection:'column'時舉例
1.垂直方向上對齊戈次,justifyContent:'flex-start'
<Text style={styles.label}>垂直方向上對齊轩勘,justifyContent:'flex-start'</Text>
<View style={[{flexDirection:'column',height:100,justifyContent:'flex-start',},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
</View>
視圖:
2.垂直方向居中對齊,justifyContent:'center'
<Text style={styles.label}>垂直方向居中對齊朝扼,justifyContent:'center'</Text>
<View style={[{flexDirection:'column',height:100,justifyContent:'center',},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
</View>
視圖:
3.垂直方向下對齊赃阀,justifyContent:'flex-end'
<Text style={styles.label}>垂直方向下對齊,justifyContent:'flex-end'</Text>
<View style={[{flexDirection:'column',height:100,justifyContent:'flex-end',},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
</View>
視圖:
4.垂直方向元素之間間隔相同擎颖,justifyContent:'space-between'
<Text style={styles.label}>垂直方向元素之間間隔相同榛斯,justifyContent:'space-between'</Text>
<View style={[{flexDirection:'column',height:100,justifyContent:'space-between',},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
</View>
視圖:
5.垂直方向元素兩邊間隔相同,justifyContent:'space-around'
<Text style={styles.label}>垂直方向元素兩邊間隔相同搂捧,justifyContent:'space-around'</Text>
<View style={[{flexDirection:'column',height:100,justifyContent:'space-around',},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
</View>
視圖:
alignItems
表示在水平方向或垂直方向子元素的對齊方式驮俗,需要配合flexDirection
使用。與之相似的還有alignSelf
允跑,alignSelf
表示自己相對于父容器的對齊方式王凑,用法與alignItems
相同。這里要注意聋丝,alignItems
與justifyContent
在flexDirection
上的對齊方向相反索烹。
當父容器flexDirection:'column'時
alignItems:'flex-start'
,表示子元素水平方向左對齊
alignItems:'center'
弱睦,表示子元素水平居中對齊
alignItems:'flex-end'
百姓,表示子元素水平方向右對齊
當父容器flexDirection:'row'時
alignItems:'flex-start'
,表示子元素垂直方向上對齊
alignItems:'center'
况木,表示子元素垂直居下對齊
alignItems:'flex-end'
垒拢,表示子元素垂直方向居中對齊
水平方向即flexDirection:'column'時舉例
1.水平方向左對齊,alignItems:'flex-start'
<Text style={styles.label}>水平方向左對齊火惊,alignItems:'flex-start'</Text>
<View style={[{flexDirection:'column',alignItems:'flex-start',},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
<Text>測試</Text>
</View>
視圖:
2.水平方向居中對齊求类,alignItems:'center'
<Text style={styles.label}>水平方向居中對齊,alignItems:'center'</Text>
<View style={[{flexDirection:'column',alignItems:'center',},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
<Text>測試</Text>
</View>
視圖:
3.水平方向右對齊屹耐,alignItems:'flex-end'
<Text style={styles.label}>水平方向右對齊尸疆,alignItems:'flex-end'</Text>
<View style={[{flexDirection:'column',alignItems:'flex-end',},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
<Text>測試</Text>
</View>
視圖:
垂直方向即flexDirection:'row'時舉例
1.垂直方向上對齊,alignItems:'flex-start'
<Text style={styles.label}>垂直方向上對齊,alignItems:'flex-start'</Text>
<View style={[{flexDirection:'row',height:50,alignItems:'flex-start',},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
<Text>測試</Text>
</View>
視圖:
2.垂直方向居中對齊仓技,alignItems:'center'
<Text style={styles.label}>垂直方向居中對齊鸵贬,alignItems:'center'</Text>
<View style={[{flexDirection:'row',height:50,alignItems:'center',},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
<Text>測試</Text>
</View>
視圖:
3.垂直方下對齊,alignItems:'flex-end'
<Text style={styles.label}>垂直方下對齊脖捻,alignItems:'flex-end'</Text>
<View style={[{flexDirection:'row',height:50,alignItems:'flex-end',},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
<Text>測試</Text>
</View>
視圖:
flexWrap
子元素超出容器時是否換行顯示:
flexWrap:'wrap'
阔逼,表示超出則換行顯示,默認超出換行顯示
flexWrap:'nowrap'
地沮,表示超出不換行顯示
舉例
1.父容器設置flexWrap:'wrap'
表明包裹內(nèi)容嗜浮,子元素超出父容器顯示范圍折行顯示,默認情況不設置flexWrap
就包裹內(nèi)容
<View style={{marginVertical:20,}}>
<Text style={{fontSize:20,color:'#333333'}}>父容器設置flexWrap:'wrap'表明包裹內(nèi)容摩疑,子元素超出父容器顯示范圍折行顯示危融,默認情況不設置flexWrap就包裹內(nèi)容</Text>
</View>
<View style={{flexWrap:'wrap',flexDirection:'row'}}>
<Text>測試</Text><Text>測試</Text><Text>測試</Text>
<Text>測試</Text> <Text>測試</Text><Text>測試</Text>
<Text>測試</Text> <Text>測試</Text><Text>測試</Text>
<Text>測試</Text><Text>測試</Text> <Text>測試</Text>
<Text>測試</Text><Text>測試</Text><Text>測試</Text>
<Text>測試</Text><Text>測試</Text><Text>測試</Text>
<Text>測試</Text><Text>測試</Text><Text>測試</Text>
</View>
視圖:
2.父容器設置flexWrap:'nowrap'
表明不包裹內(nèi)容,子元素超出父容器部分不被顯示雷袋,默認情況不設置flexWrap
就包裹內(nèi)容
<View style={{marginVertical:20,}}>
<Text style={{fontSize:20,color:'#333333'}}>父容器設置flexWrap:'nowrap'表明不包裹內(nèi)容吉殃,子元素超出父容器部分不被顯示,默認情況不設置flexWrap就包裹內(nèi)容</Text>
</View>
<View style={{flexWrap:'nowrap',flexDirection:'row'}}>
<Text>測試</Text><Text>測試</Text><Text>測試</Text>
<Text>測試</Text> <Text>測試</Text><Text>測試</Text>
<Text>測試</Text> <Text>測試</Text><Text>測試</Text>
<Text>測試</Text><Text>測試</Text> <Text>測試</Text>
<Text>測試</Text><Text>測試</Text><Text>測試</Text>
<Text>測試</Text><Text>測試</Text><Text>測試</Text>
<Text>測試</Text><Text>測試</Text><Text>測試</Text>
</View>
視圖:
position
position:'absolute'
楷怒,表示絕對布局蛋勺;通過top
,left
鸠删,bottom
抱完,right
指定相對于父容器的位置,默認不設置為相對布局刃泡。
<View style={{marginVertical:20,}}>
<Text style={{fontSize:20,color:'#333333'}}>絕對位置</Text>
</View>
<View style={{height:116,borderWidth:1,margin:5}}>
<Text style={{fontSize:16,position:'absolute',left:20,top:50}}>局對垂直居中</Text>
</View>
視圖:
以下貼出全部測試代碼
'use strict';
import React, {ScrollView,Text,View,StyleSheet,AppRegistry} from 'react-native';
class Demo extends Component {
render() {
return (
<ScrollView style={{paddingTop:30}}>
<Text style={styles.label}>父容器默認情況下(flexDirection:'column')子元素從上到下垂直排列巧娱,此時子元素默認水平方向填充父容器;子元素flex:1,在垂直方向起作用,表示垂直方向占滿父容器空間</Text>
<View style={[styles.container,{height:80}]}>
<View style={{backgroundColor:'red',flex:1}}></View>
<View style={{height:20,backgroundColor:'green'}}></View>
</View>
<Text style={styles.label}>父容器flexDirection:'row'時子元素從左到右水平排列;flex:1在水平方向起作用烘贴,表示水平方向占滿全部父容器空間</Text>
<View style={[{height:60,flexDirection:'row'},styles.container]}>
<View style={{height:20,flex:1,backgroundColor:'red'}}></View>
<View style={{height:20,width:100,backgroundColor:'green',}}></View>
</View>
<Text style={styles.label}>父容器flexDirection:'column'禁添,只有一個子元素;子元素flex:1,占滿全部父容器空間,子元素height不起作用</Text>
<View style={[{height:100,flexDirection:'column'},styles.container]}>
<View style={{flex:1,backgroundColor:'red',height:10,}}></View>
</View>
<Text style={styles.label}>父容器flexDirection:'row'桨踪,只有一個子元素;子元素flex:1,占滿全部父容器空間,子元素width不起作用</Text>
<View style={[{height:100,flexDirection:'row'},styles.container]}>
<View style={{flex:1,backgroundColor:'red',width:10}}></View>
</View>
<Text style={styles.label}>父容器flexDirection:'row'上荡,子元素在水平方向按比例分配父容器空間</Text>
<View style={[{height:40,flexDirection:'row'},styles.container]}>
<View style={{flex:1,backgroundColor:'red',height:20}}></View>
<View style={{flex:2,backgroundColor:'green',height:20}}></View>
</View>
<Text style={styles.label}>父容器flexDirection:'column',子元素在垂直方向按比例分配父容器空間</Text>
<View style={[{height:100,flexDirection:'column'},styles.container]}>
<View style={{flex:1,backgroundColor:'red',width:20}}></View>
<View style={{flex:1,backgroundColor:'green',width:20}}></View>
</View>
<Text style={styles.label}>默認情況下父容器flexDirection:'column'馒闷,子元素從上到下垂直排列</Text>
<View style={[{},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
</View>
<Text style={styles.label}>父容器flexDirection:'column',子元素從左到右水平排列</Text>
<View style={[styles.container,{flexDirection:'row'}]}>
<Text>測試</Text>
<Text>測試</Text>
<Text>測試</Text>
</View>
<Text style={styles.label}>父容器flexDirection:'column'叁征,子元素從上到下垂直排列纳账,與默認情況父容器不設置flexDirection相同</Text>
<View style={[{flexDirection:'column',},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
<Text>測試</Text>
</View>
<View style={{marginVertical:20,}}><Text style={{fontSize:20,color:'#333333'}}>子元素元素水平排列</Text></View>
<Text style={styles.label}>水平方向左對齊,justifyContent:'flex-start'</Text>
<View style={[{flexDirection:'row',justifyContent:'flex-start'},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
<Text>測試</Text>
</View>
<Text style={styles.label}>水平方向居中對齊捺疼,justifyContent:'center'</Text>
<View style={[{flexDirection:'row',justifyContent:'center'},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
<Text>測試</Text>
</View>
<Text style={styles.label}>水平方向右對齊疏虫,justifyContent:'flex-end'</Text>
<View style={[{flexDirection:'row',justifyContent:'flex-end'},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
<Text>測試</Text>
</View>
<Text style={styles.label}>水平方向元素之間間隔相同,justifyContent:'space-between'</Text>
<View style={[{flexDirection:'row',justifyContent:'space-between'},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
<Text>測試</Text>
</View>
<Text style={styles.label}>水平方向元素兩邊間隔相同,justifyContent:'space-around'</Text>
<View style={[{flexDirection:'row',justifyContent:'space-around'},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
<Text>測試</Text>
</View>
<Text style={styles.label}>垂直方向上對齊卧秘,alignItems:'flex-start'</Text>
<View style={[{flexDirection:'row',height:50,alignItems:'flex-start',},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
<Text>測試</Text>
</View>
<Text style={styles.label}>垂直方向居中對齊呢袱,alignItems:'center'</Text>
<View style={[{flexDirection:'row',height:50,alignItems:'center',},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
<Text>測試</Text>
</View>
<Text style={styles.label}>垂直方下對齊,alignItems:'flex-end'</Text>
<View style={[{flexDirection:'row',height:50,alignItems:'flex-end',},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
<Text>測試</Text>
</View>
<View style={{marginVertical:20,}}><Text style={{fontSize:20,color:'#333333'}}>子元素元素垂直排列</Text></View>
<Text style={styles.label}>水平方向左對齊翅敌,alignItems:'flex-start'</Text>
<View style={[{flexDirection:'column',alignItems:'flex-start',},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
<Text>測試</Text>
</View>
<Text style={styles.label}>水平方向居中對齊羞福,alignItems:'center'</Text>
<View style={[{flexDirection:'column',alignItems:'center',},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
<Text>測試</Text>
</View>
<Text style={styles.label}>水平方向右對齊,alignItems:'flex-end'</Text>
<View style={[{flexDirection:'column',alignItems:'flex-end',},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
<Text>測試</Text>
</View>
<Text style={styles.label}>垂直方向上對齊蚯涮,justifyContent:'flex-start'</Text>
<View style={[{flexDirection:'column',height:100,justifyContent:'flex-start',},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
</View>
<Text style={styles.label}>垂直方向居中對齊治专,justifyContent:'center'</Text>
<View style={[{flexDirection:'column',height:100,justifyContent:'center',},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
</View>
<Text style={styles.label}>垂直方向下對齊,justifyContent:'flex-end'</Text>
<View style={[{flexDirection:'column',height:100,justifyContent:'flex-end',},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
</View>
<Text style={styles.label}>垂直方向元素之間間隔相同遭顶,justifyContent:'space-between'</Text>
<View style={[{flexDirection:'column',height:100,justifyContent:'space-between',},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
</View>
<Text style={styles.label}>垂直方向元素兩邊間隔相同张峰,justifyContent:'space-around'</Text>
<View style={[{flexDirection:'column',height:100,justifyContent:'space-around',},styles.container]}>
<Text>測試</Text>
<Text>測試</Text>
</View>
<View style={{marginVertical:20,}}><Text style={{fontSize:20,color:'#333333'}}>父容器設置flexWrap:'wrap'表明包裹內(nèi)容,子元素超出父容器顯示范圍折行顯示棒旗,默認情況不設置flexWrap就包裹內(nèi)容</Text></View>
<View style={{flexWrap:'wrap',flexDirection:'row'}}>
<Text>測試</Text><Text>測試</Text><Text>測試</Text><Text>測試</Text>
<Text>測試</Text><Text>測試</Text><Text>測試</Text>
<Text>測試</Text><Text>測試</Text><Text>測試</Text><Text>測試</Text>
<Text>測試</Text><Text>測試</Text><Text>測試</Text><Text>測試</Text>
<Text>測試</Text><Text>測試</Text><Text>測試</Text>
<Text>測試</Text><Text>測試</Text><Text>測試</Text><Text>測試</Text>
</View>
<View style={{marginVertical:20,}}><Text style={{fontSize:20,color:'#333333'}}>父容器設置flexWrap:'nowrap'表明不包裹內(nèi)容喘批,子元素超出父容器部分不被顯示,默認情況不設置flexWrap就包裹內(nèi)容</Text></View>
<View style={{flexWrap:'nowrap',flexDirection:'row'}}>
<Text>測試</Text><Text>測試</Text><Text>測試</Text><Text>測試</Text>
<Text>測試</Text><Text>測試</Text><Text>測試</Text>
<Text>測試</Text><Text>測試</Text><Text>測試</Text><Text>測試</Text>
<Text>測試</Text><Text>測試</Text><Text>測試</Text><Text>測試</Text>
<Text>測試</Text><Text>測試</Text><Text>測試</Text>
<Text>測試</Text><Text>測試</Text><Text>測試</Text><Text>測試</Text>
</View>
<View style={{marginVertical:20,}}><Text style={{fontSize:20,color:'#333333'}}>絕對位置</Text></View>
<View style={{height:116,borderWidth:1,margin:5}}>
<Text style={{fontSize:16,position:'absolute',left:20,top:50}}>局對垂直居中</Text>
</View>
</ScrollView>
);
}
}
const styles = StyleSheet.create({
container: {
borderWidth:1,
padding:5,
margin:5,
},
label: {
color:'#333333',
margin:5,
},
});
AppRegistry.registerComponent('Demo', () => Demo);