android - 在反应原生android中隐藏和显示时,TouchableOpacity 在绝对视图中不起作用
问题描述
在我现在正在编码的应用程序中,我创建了一个按钮,当我单击显示视图时。在那个观点上,有一个段落,在那个“这里”链接到一个网页。单击该链接时,我需要打开一个网站。位置“相对”它正在工作,但“绝对”位置不是,请帮我解决这个问题。我尝试了很多答案,但对我的情况不起作用!
代码:
<View style={iconStyle}>
<Pressable
style={styles.container}
onPress={() => {
setEnabled(!enabled);
}}>
<Icon />
</Pressable>
{enabled && (
<View style={[styles.content, contentStyle]}>
<Text style={styles.text}>
{content}{' '}
{link && linkText && (
<TouchableOpacity onPress={() => console.log('clicked')}>
<Text>here</Text>
</TouchableOpacity>
)}
</Text>
</View>
)}
</View>
风格
const styles = StyleSheet.create({
container: {
width: 25,
height: 20,
},
content: {
position: 'absolute',
marginBottom: 30,
top: 25,
zIndex: 1000,
borderRadius: 5,
padding: 8,
width: 200,
left: 0,
backgroundColor: colors.green,
},
text: {
justifyContent: 'space-between',
fontSize: 12,
fontFamily: fonts.regular,
},
linkText: {
color: colors.darkBlue,
textDecorationLine: 'underline',
},
});
解决方案
推荐阅读
- c++ - 在模板的帮助下,C++ 构造函数根据输入表现不同
- javascript - Shiny/DT:在初始加载时显示子行
- javascript - JavaScript setMinutes() 在 DST 结束时表现错误
- r - R:无法使用特征的平方进行线性回归
- reactjs - React-router-dom:路由未显示预期结果
- jenkins - Jenkins API 更新库配置
- python - Python使用多线程组合熊猫数据框
- python - 需要在 Python 3.7 版本中停止执行方法
- java - 检查子列表是否以相同的顺序在列表中
- mysql - MySQL在多列中使用通配符匹配一个值