Copy <View style={styles.row}
onLayout={(event) => {
var {x, y, width, height} = event.nativeEvent.layout;
}
}/>
字體大小不被系統字體大小影響(just for iOS)
Copy Text.defaultProps.allowFontScaling = false;
Copy import { Dimensions, } from 'react-native'
export var windowH = Dimensions.get('window').height;
export var windowW = Dimensions.get('window').width;
or
var {height, width} = Dimensions.get('window')
Copy import { Keyboard } from 'react-native'
...
constructor() {
super();
this.state = {
//change money's input position
isKeyboardShow: true,
//for ios's softkeyboard
keyboardHeight: 0,
}
}
componentWillMount() {
this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', (e) => this.keyboardDidShow(e));
this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', () => this.keyboardDidHide());
}
componentWillUnmount() {
this.keyboardDidShowListener.remove();
this.keyboardDidHideListener.remove();
}
keyboardDidShow(e) {
this.setState({
isKeyboardShow: true,
keyboardHeight: e.endCoordinates.height, //測量鍵盤高度
});
}
keyboardDidHide() {
this.setState({
isKeyboardShow: false,
keyboardHeight: 0,
});
}
...