reactjs - React Native alignSelf center and stretch to maxWidth? -
i have following
<view style={{maxwidth: 700}}> <view style={{backgroundcolor: 'red', flexdirection: 'row', justifycontent: 'space-between'}}> <text>left item</text> <text>right item</text> </view> </view> which working i'd expect on large device (vertical black lines edges of emulator screen).
all center on screen.
when attempt adding alignself: 'center' parent
<view style={{maxwidth: 700, alignself: 'center'}}> <view style={{backgroundcolor: 'red', flexdirection: 'row', justifycontent: 'space-between'}}> <text>left item</text> <text>right item</text> </view> </view> the width lost.
i assume because default alignself 'stretch'. there way both stretch content use maxwidth , center on screen?
try using flex:1 along maxwidth both make stretch limit width 700
<view style={{flexdirection:'row', alignitems: 'center', justifycontent: 'center'}}> <view style={{flex:1, maxwidth: 700, backgroundcolor:'red', flexdirection:'row', justifycontent:'space-between'}}> <text>left item</text> <text>right item</text> </view> </view> 

Comments
Post a Comment