-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Android] measure not returning values unless element has onLayout property #3282
Comments
@oblador what happens if, instead of logging |
@foghina: they log as |
@foghina: in case you don't know of |
@oblador I know about Can you try wrapping the measure call in this.requestAnimationFrame(() => {
this._root.measure((ox, oy, width, height, px, py) => {
console.log(arguments);
});
}); |
@foghina "arguments" in an arrow function refers to the enclosing non-arrow function's arguments (same scoping as "this"). Maybe that was the issue you were seeing. |
@ide that does not explain why it works on iOS :-/ |
There was a timing change with how iOS does measurement that may have fixed this issue. Haven't really looked into it in detail, but it might be related? aa62a5e |
I've updated the issue to not confuse anybody. It works as expected on iOS for all I know, but not on android. Wasn't aware of arrow functions inheriting the |
@oblador does wrapping the call in a rAF callback help? |
@ide haven't tried, but don't really understand why it would make a difference. |
Yeah you're probably right. |
I'm also experiencing this. Along with |
@oblador @marcshilling can you try I just ran into something similar. https://facebook.github.io/react-native/docs/view.html#content |
I have same problem and can confirm that using |
@chirag04 collapsable: false helped for me, thanks. |
@facebook-github-bot close |
@chirag04 tells me to close this issue. If you think it should still be opened let us know why. |
FYI, I'm using 0.26.3 and this was still an issue. I had to add an empty |
I am having trouble with this on iOS as well. |
Was this fixed in a more recent version? Using the unrelated properties |
@chirag04 you closed this but it's actually not resolved.
Also the y position (second argument) is always 0 if the element you are measuring is in a scroll view (with collapsable) . Joy. |
I can confirm the bug is still here |
i am using react native version 0.36 and got this issues on Android, but on iOS it work well
height is undefined |
setting |
@chirag04 |
I was still experiencing the issue with collapsable={false}. What fixed it for me was adding onLayout={() => {}} instead. |
Using |
I was experiencing this issue on Views and managed to work around it by adding empty onLayout as suggested. However now I am trying to measure a ScrollView and adding onLayout did not fix the issue. I managed to work around it by wrapping all the content of my ScrollView with a View, adding an empty onLayout to that View, and then measuring that View. |
Relative react-native issue: facebook/react-native#3282
Relative react-native issue: facebook/react-native#3282
Relative react-native issue: facebook/react-native#3282
I have the same problem, but props arent undefined. I have a listview with this rows:
With
On iOS measure logs:
On Android measure logs:
Why my oy on android is always 0? |
I just found that on iOS, measuring a Text component nested in another Text component results in all 0's as well. Haven't tested on Android yet. Also noted that onLayout on a nested Text component is never called, very strange. |
@SteffeyDev I think it have something to do with the way they render nested Text Component. Basically they used attributed text on the outermost Text element and all the nested ones are parsed to be merged into the parent as 1 large text item. That's how I think it's on iOS. |
@joturako That makes sense, and explains why I can't get layout information. If I have a large body of text in a scrollview, how would you recommend I find the position of a smaller portion so that I can scroll there? Or is there no way to do that? |
@SteffeyDev I think you have to write a custom component, for iOS for example you can look for more information on how to scroll a |
Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally! If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:
If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution. |
I know this is closed but for anyone else who hit this when trying to get the x and y coordinates within a For example:
|
Still hitting this issue when using |
I have something similar to this:
This code works flawlessly on iOS, but on android the measure callback will always be called with
undefined
arguments – unless I put an empty callback on theonLayout
property.The text was updated successfully, but these errors were encountered: