Android上,在带有ImageBackground的标题栏中,Buttons或TouchableOpacity不可点击。
创始人
2024-10-10 08:00:51
0

在标题栏中使用TouchableOpacityWrapper作为父容器,并手动传递触摸事件。

TouchableOpacityWrapper示例代码如下:

import React from 'react'; import {TouchableOpacity, View} from 'react-native';

class TouchableOpacityWrapper extends React.Component { render() { return ( {this.props.children} {}} /> ); } }

使用TouchableOpacityWrapper作为标题栏容器:

import React from 'react'; import {ImageBackground, StyleSheet, Text, View} from 'react-native'; import TouchableOpacityWrapper from './TouchableOpacityWrapper';

class HeaderWithBackgroundImage extends React.Component { render() { return ( Header Title console.log('Button clicked!')}> Button Text ); } }

const styles = StyleSheet.create({ image: { width: '100%', height: 200, }, header: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingHorizontal: 16, paddingTop: 52, paddingBottom: 16, }, title: { color: '#fff', fontSize: 20, fontWeight: 'bold', }, button: { color: '#fff', fontSize: 16, fontWeight: 'bold', }, });

在上述示例代码中,TouchableOpacityWrapper组件的位置是在ImageBackground组件中,同时也包含Button或TouchableOpacity组件作为子组件。触摸事件会传递给TouchableOpacityWrapper组件,然后手动传递给子组件,以使它们可点击。

相关内容

热门资讯

透视线上"哈糖大菠萝... 1、透视线上"哈糖大菠萝有挂吗5个常用方法"详细辅助技巧教程(作弊神器);详细教程。2、哈糖大菠萝有...
透视安卓版"hhpo... 《透视安卓版"hhpoker到底可以作弊码"详细辅助大神讲解(私人局俱乐部辅助技巧)》 hhpoke...
透视app"wepo... 透视app"wepoker代打辅助机器人"详细辅助爆料教程(私人局有透视技巧)是一款可以让一直输的玩...
透视app"wepo... 透视app"wepoker辅助器下载"详细辅助介绍教程(免费辅助器技巧)这是由厦门游乐互动科技有限公...
透视中牌率"拱趴大菠... 1、透视中牌率"拱趴大菠萝万能挂"详细辅助插件教程(透视底牌技巧)(UU poker、拱趴大菠萝万能...
透视存在"wepok... 透视存在"wepoker一直输的号能继续打吗"详细辅助玩家教程(辅助软件价格神器)科技教程也叫必备教...
透视好友房"xpok... 透视好友房"xpoker辅助怎么用"详细辅助分享教程(私人局俱乐部软件)1、许多玩家不知道xpoke...
透视总结"wepok... 透视总结"wepoker透视方法"详细辅助介绍教程(私人局可以玩技巧);建议优先通过wepoker透...
透视实锤"hhpok... 透视实锤"hhpoker万能辅助器"详细辅助插件教程(透视脚本视频辅助);1分钟了解详细教程(微信 ...
透视ai"wepok... 透视ai"wepoker有辅助功能吗"详细辅助AA德州教程(免费透视脚本辅助);实战中需综合运用上述...