-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Closed
Labels
BugPlatform: AndroidAndroid applications.Android applications.StaleThere has been a lack of activity on this issue and it may be closed soon.There has been a lack of activity on this issue and it may be closed soon.
Description
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:
- OS: macOS High Sierra 10.13.4
- Node: 9.9.0
- Yarn: 1.5.1
- npm: 6.0.1
- Watchman: 4.6.0
- Xcode: Xcode 9.3.1 Build version 9E501
- Android Studio: 2.3 AI-162.4069837
Packages: (wanted => installed)
- react: 16.3.1 => 16.3.1
- react-native: ~0.55.2 => 0.55.4
Steps to Reproduce
Create a new app using CRNA/Expo and change App.js
like this:
/* @flow */
import * as React from "react";
import { StyleSheet, View, findNodeHandle } from "react-native";
// $FlowFixMe
import NativeMethodsMixin from "NativeMethodsMixin";
class AndroidMeasureTester extends React.Component<{}> {
boxRef: ?View = null;
handleBoxLayout = () => {
if (this.boxRef) {
NativeMethodsMixin.measureInWindow.call(
findNodeHandle(this.boxRef),
(x, y, width, height) => {
console.debug("RED BOX LAYOUT:");
console.debug("x", x);
console.debug("y", y);
console.debug("width", width);
console.debug("height", height);
}
);
}
};
render() {
return (
<View style={styles.container}>
<View
style={styles.box}
ref={ref => (this.boxRef = ref)}
onLayout={this.handleBoxLayout}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
height: "100%",
width: "100%"
},
box: {
width: 80,
height: 80,
backgroundColor: "red"
}
});
export default AndroidMeasureTester;
I also create an Expo Snack.
Expected Behavior
The measured Y coordinate should be 0 (it's printed on console):
x: 0
y: 0
width: 80
height: 80
Actual Behavior
The measured Y coordinate is -24 (it's printed on console):
x: 0
y: -24
width: 80
height: 80
Image recap
loiclouvet, xiaweiss, rawrmaan, KakarN, wxlworkhard and 3 more
Metadata
Metadata
Assignees
Labels
BugPlatform: AndroidAndroid applications.Android applications.StaleThere has been a lack of activity on this issue and it may be closed soon.There has been a lack of activity on this issue and it may be closed soon.