我試圖用右視圖和左視圖(圖像兩端)的Textfield構建搜索組件。文本輸入將自身包裝爲內容的長度,因此組件不覆蓋整個父寬度。如何拉伸組件以使整個組件佔據父項的全部寬度。使用左視圖和右視圖模式反應本地文本輸入
<View style={{flexDirection:'row', height:40,alignSelf:'stretch',backgroundColor:'red'}}>
<Image source={require('./image_assets_rn/search_rn.png')} style={{alignSelf:'center',}}/>
<TextInput placeholder="Search Jet" style={{backgroundColor:'white',alignSelf:'stretch',}}/>
<Image source={require('./image_assets_rn/search_rn.png')} style={{alignSelf:'center',}}/>
</View>
以下是輸出。我想伸展沿主軸線(寬度)的文本框
有趣!文本輸入假設推開第二個圖標 – Itzdsp