簡體   English   中英

React Native - 如何將兩個不同的半背景顏色添加到<text></text>

[英]React Native - How to add two different half backgroundColor to <Text></Text>

React Native - 如何將兩個不同的半backgroundColor顏色添加到圖像中給出的<Text></Text> 例如(黑色高度 50%,白色高度 50% )。 內容應該是adaptive width

<Text style={styles.inputLabel}>Lorem ipsum dolor sit am</Text>

在此處輸入圖像描述

這是否可以在本機反應中創建設計。

您可以執行以下操作,使用絕對 position 的另一個視圖進行視圖包裝,該視圖將具有 50% 的高度和背景色。

  <View>
      <View style={{position:'absolute'}}>
        <View style={{height:'50%',backgroundColor:'black',width:'100%',position:'absolute'}}/>
        <Text style={{color:'red',zIndex:1000}}>Some text here 12213 1312  223</Text>
        </View>
  </View>

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM