首页 > 解决方案 > 文本和 TouchableOpacity 文本没有出现在直线上

问题描述

我试图在纯文本旁边加上一些可触摸的不透明度,但是,两个可触摸之间的纯文本与可触摸的文本不一致。请指导如何解决这个问题。

<Text style={{fontSize:10,textAlign:'center',}}>By clicking Sign up, you agree to Company's <TouchableOpacity ><Text style={{fontSize:10, color:'blue'}}>Terms of Service</Text></TouchableOpacity> and <TouchableOpacity><Text style={{fontSize:10, color:'blue'}}>Privacy Policy.</Text></TouchableOpacity></Text>  

它在物理设备上呈现这样

标签: react-nativetexttext-alignmenttouchableopacity

解决方案


不需要,touchableopacity因为TextonPress道具。

<Text style={{fontSize:10,textAlign:'center'}}>

    By clicking Sign up, you agree to Companys 

    <Text 
      onPress={() => alert("Terms of Service is clicked")} 
      style={{fontSize:10, color:'blue'}}>
      Terms of Service
    </Text>

    and

   <Text 
      onPress={() => alert("Privacy Policy is clicked")} 
      style={{fontSize:10, color:'blue'}}>
      Privacy Policy.
   </Text>

</Text>  

推荐阅读