TouchableHighlight反应本机按钮图像正在显示,但未被点击

时间:2018-06-24 19:49:40

标签: javascript css react-native

由于样式设置,我试图使图像作为按钮,但我的按钮没有被单击。我已将此代码添加到scrollView中。 如果我将其设为相对位置,则按钮的位置将在屏幕开始时处于打开状态,并且可以工作,但不能在绝对位置工作

loadbutton: {
  alignItems: 'center',
  position: 'absolute',
//  justifyContent: 'center',
  top: 1200,
//  bottom: 10,
//  left: width/6
//  borderRadius: 5,
},

  <TouchableHighlight onPress={Actions.DrScreen}
      style={styles.loadbutton}
      >
        <Image
        
          resizeMode="cover"
          source={require("../../images/start.png")}
        />
      </TouchableHighlight>

2 个答案:

答案 0 :(得分:0)

尝试一下:

<TouchableHighlight onPress={() => {Actions.DrScreen}}
      style={styles.loadbutton}
      >
        <Image

          resizeMode="cover"
          source={require("../../images/start.png")}
        />
      </TouchableHighlight>

答案 1 :(得分:0)

通过更改marginTop而不是top解决了它

loadbutton: {
//  alignItems: 'center',
  marginTop: 1200,
  paddingBottom: 30,
  //position: 'absolute',
  //justifyContent: 'center',
//  top: 100,
 //bottom: 100,
   left: width/6+2
//  borderRadius: 5,
},

相关问题