Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do i make views clickable through in react native

I have multiple buttons structured like this:

<View style={ { height: '100%', width: '10%', transform: rotate } }> // being transformed by rotation inside panResponder
   <View {panresponder}/> // takes the touch event
   <Image/> 
</View>

The Problem

If there are two cursors 180 degrees away from eachother, the tail end of the encapsulating View will take the touch that was meant for the touchable view of the other.

The Aim

I want to be able to click the touchable view at any time even if it is being overlapped by a View. how do i make a View clickable through? Is there a way to layer zIndex that it would make the clickable view rise above other views?(ive been fiddling with zIndex and it makes the components disappear).

like image 572
Tierna D. Jack Lawless Avatar asked Oct 24 '25 00:10

Tierna D. Jack Lawless


2 Answers

You can use

<TouchableOpacity onPress={}> or <TouchableWithoutFeedback  onPress={}>

to make anything clickable

like image 103
gamingumar Avatar answered Oct 25 '25 17:10

gamingumar


You can use like this,

<TouchableHighlight style={styles.button} underlayColor={"COLOR"} style = {styles.button} onPress = {() => this.onClickView()}>
   <View />
</TouchableHighlight>
like image 45
Pratik S. Gode Avatar answered Oct 25 '25 17:10

Pratik S. Gode