Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native onLayout nativeEvent.layout.y always returns 0

I'm creating a grid of Views. I'm doing it using pure flex. i.e. no absolute positioning. Actual screenshot:

Actual screenshot

I need to know the positions of each View in the grid and for that I'm using the onLayout prop. The problem is that the y value on evt.nativeEvent.layout is always zero, the rest of the values (x, height, width) are fine. I'm testing only in Android, using Genymotion and a physical Sony Xperia device (both with Android 6.0.1).

Any ideas of why the y value is 0?

React Native version: react-native: 0.40.0, react-native-cli: 1.2.0

Thanks for your help.

like image 701
Heiner Avatar asked Jan 25 '17 21:01

Heiner


1 Answers

Ok.. I was suspecting that so I ended up saving the row's Y position and then assigning it to the "cells". Thanks for your help @HaitaoLi

like image 78
Heiner Avatar answered Nov 15 '22 10:11

Heiner