android - How to expand view width to available free space in react native -


hi trying design screen in react native. if see below screenshot here 3 views there. a) image b) center view text appeared c) circle view

i want expand center view width such covers complete available space. tried using flex property couldn't make it. know how ?

enter image description here

<view style={{ flexdirection: "column" }}>   <view style={{ flexdirection: "row" }}>     <icon name="user" size={30} />     <text       style={{         textalignvertical: "center",         marginleft: 20       }}     >       ajay saini     </text>   </view>   <text style={{ marginleft: 50 }}>hello</text> </view>   <view style={{ flexdirection: "row", width: "100%" }}>   <icon name="user" size={30} />   <view     style={{       flex: 1,       flexdirection: "column",       marginleft: 20     }}   >     <text>williams</text>     <text>       {item.text}jhfjks ahfdkjsdh fjkshfjksaddhfjksdahfjkds       ahajkdhfjksahdf     </text>   </view>   <view     style={{       flex: 1,       flexdirection: "row",       justifycontent: "flex-end"     }}   >     <touchableopacity       style={{         borderwidth: 1,         bordercolor: "rgba(0,0,0,0.2)",         alignitems: "center",         justifycontent: "center",         width: 30,         height: 30,         backgroundcolor: "#fff",         borderradius: 100       }}     />   </view> </view> 

since circular view has flex: 1, tries occupy free space. also, center view tries same. results in splitting free space evenly, therefore removing flex: 1 style circular view enough.

additionally, can try adding justifycontent: 'space-between' outer view. great option simplify more complicated designs.

<view style={{ flexdirection: 'row' }}>   <icon name="user" size={30} />   <view     style={{       flex: 1,       flexdirection: "column",       marginleft: 20     }}   >     <text>williams</text>     <text>       {item.text}jhfjks ahfdkjsdh fjkshfjksaddhfjksdahfjkds       ahajkdhfjksahdf     </text>   </view>   <view     style={{       flexdirection: "row",       justifycontent: "flex-end"     }}   >     <touchableopacity       style={{         borderwidth: 1,         bordercolor: "rgba(0,0,0,0.2)",         alignitems: "center",         justifycontent: "center",         width: 30,         height: 30,         backgroundcolor: "#fff",         borderradius: 100       }}     />   </view> </view> 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -