Search code examples
buttonreact-nativerow

How to put button over row In react-native?


I have text and image in one row. and now I want to put button over the row with exact size of row.

used flexDirection: 'row'

Any help?


Solution

  • You can wrap your text and image inside the TouchableOpacity component

    <TouchableOpacity onPress={() => doYourThing()}>
      <Text>{yourText}</Text>
      <Image source={{}} />
    </TouchableOpacity>
    

    If the text and image are already wrapped in a View, you can just replace the View component with the TouchableOpacity component. It takes all the props which View takes.