Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/367.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 反应本机-为什么我的图像按钮在Android上闪烁?_Javascript_React Native_React Native Android - Fatal编程技术网

Javascript 反应本机-为什么我的图像按钮在Android上闪烁?

Javascript 反应本机-为什么我的图像按钮在Android上闪烁?,javascript,react-native,react-native-android,Javascript,React Native,React Native Android,我有一个简单的图像按钮,可以在TouchStart和onRelease上更改其图像。在iOs上,它像预期的那样工作,但在Android上,当图像发生变化时,按钮会闪烁。 看起来,如果每次我触摸图像时都必须再次加载图像 类MyApp扩展了React.Component{ 构造器{ 超级作物; } 渲染{ 回来 ; } } 类ImageButton扩展React.Component{ constructorprops:{}{ 超级作物; 此.image={ 正常:需要“./img/button.p

我有一个简单的图像按钮,可以在TouchStart和onRelease上更改其图像。在iOs上,它像预期的那样工作,但在Android上,当图像发生变化时,按钮会闪烁。 看起来,如果每次我触摸图像时都必须再次加载图像

类MyApp扩展了React.Component{ 构造器{ 超级作物; } 渲染{ 回来 ; } } 类ImageButton扩展React.Component{ constructorprops:{}{ 超级作物; 此.image={ 正常:需要“./img/button.png”, 突出显示:需要“./img/button toucted.png” }; 此.state={ 图像:this.image.normal }; } onTouchStart{ //做点什么 //设置高亮显示的图像 这是我的国家{ image:this.image.highlight }; } onTouchEnd{ 这是我的国家{ 图像:this.image.normal } } onTouchCancel{ 这是我的国家{ 图像:this.image.normal }; } 组件将接收props外部props{ 这是我的国家{ 图像:nextrops.image.normal }; } 渲染{ 回来 真的} onResponderGrant={this.onTouchStart.bindthis} onResponderRelease={this.onTouchEnd.bindthis} onResponderTerminate={this.onTouchCancel.bindthis} OnResponderObject={this.onTouchCancel.bindthis}> ; } } const styles=StyleSheet.create{ 容器:{ 弹性:1, 为内容辩护:“中心”, 对齐项目:“居中”, 背景颜色:“E4”, }, 按钮:{ 背景色:“透明”, }, };
AppRegistry.registerComponent'schwein',=>schwein 图像在每个平台afaik上的实现略有不同,因此这确实可能发生。我建议在开始时使用这些图像创建组件,然后使用样式定义的不透明度控制其可见性。它应该像你期望的那样工作,不闪烁