-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
measureInWindow returns an incorrect Y coord on Android #19497
Comments
A Twitter comment highlighted an interesting point:
Is the Y coord starting from -24 for keeping Android <5 backward compatibility? Just to clarify: the main issue is that all the other measurement options (e.g.: XY coord obtained from a gesture) do not start from -24. |
Hi @mmazzarolo import React from "react";
import { StyleSheet, Text, View } from "react-native";
export default class App extends React.Component {
_onLayout = ({
nativeEvent: {
layout: { x, y, width, height }
}
}) => {
console.log("x", x);
console.log("y", y);
console.log("width", width);
console.log("height", height);
};
render() {
return (
<View style={styles.container}>
<View style={styles.box} onLayout={this._onLayout} />
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1
},
box: {
width: 80,
height: 80,
backgroundColor: "red"
}
}); see this: onLayout Documentation let me know if I got you right or if I can help you further. |
Hey @anteloe ! My point here was just reporting the Thanks for the snippet anyway, it might be useful to someone looking for a valid alternative. |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions. |
Nope |
I have the same problem, but on iOS. In the simulator, it seems to be correct, but when running on a real device, the In addition to that, i'm getting this warning when i use
|
@lucasmotta is it a bug? That’s the behavior I would expect from the translucent StatusBar (and I don’t think is related to this issue) 🤔 |
@mmazzarolo you are right, that's the expected behaviour. I had issue on Android only because my view was also wrapped on a |
I was using |
+1 |
This issue still occur with Android device |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions. |
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information. |
Description
Measuring an Android View using
NativeMethodsMixin.measureInWindow
returns the incorrect Y coordinate.It seems it always subtracts 24 (I guess it's the
StatusBar
height) from the Y coordinate.It returns the correct value on iOS.
Environment
Environment:
Packages: (wanted => installed)
Steps to Reproduce
Create a new app using CRNA/Expo and change
App.js
like this:I also create an Expo Snack.
Expected Behavior
The measured Y coordinate should be 0 (it's printed on console):
Actual Behavior
The measured Y coordinate is -24 (it's printed on console):
Image recap
The text was updated successfully, but these errors were encountered: