Javascript ImageBackground包装中的React本机文本未显示(带有图像)
当我将imageStyle position设置为relative时,imagebackground包装中的文本不会显示Javascript ImageBackground包装中的React本机文本未显示(带有图像),javascript,css,reactjs,react-native,react-redux,Javascript,Css,Reactjs,React Native,React Redux,当我将imageStyle position设置为relative时,imagebackground包装中的文本不会显示 <TouchableWithoutFeedback style={{ position: 'relative', flex: 1, justifyContent: 'center' }} delayPressIn={500} onPressIn={() => this.onPressInMic()} onPressOut={() => this.on
<TouchableWithoutFeedback style={{ position: 'relative', flex: 1, justifyContent: 'center' }} delayPressIn={500} onPressIn={() => this.onPressInMic()} onPressOut={() => this.onPressOutMic()}>
<ImageBackground imageStyle={{ position: 'relative', backgroundColor: 'transparent' }} source={this.state.micOn ? Images.micOn : Images.micOff} >
{
this.state.micOn
? (
<Text style={styles.micText}>PRESS TO{'\n'}STOP</Text>)
: (
<Text style={styles.micText}>PRESS TO{'\n'}RECORD</Text>
)
}
</ImageBackground>
</TouchableWithoutFeedback>
this.onPressInMic()}onPressOut={()=>this.onPressOutMic()}>
{
这个州,米肯
? (
按以{'\n'}停止)
: (
按以录制{'\n'}
)
}
文本应该位于图像内部,如
默认情况下,
ImageBackground
带有样式
通过将position:'relative'
设置为图像样式
,您将使其相对于视图容器,如定义所示。因此,子元素将始终位于ImageBackground
解决方法是删除样式中的位置:'relative'
,并使用父容器样式
对象
由于
ImageBackground styles={'/…View container styles'}
您的文本似乎隐藏在计时器下方,您能否添加相关代码来生成此问题?@PritishVaidya Hi请查看添加的图像。文本应该在图像内部