use*_*014 6 android react-native
不知何故position: 'absolute'在Android中不起作用。它适用于 iOS,但在 Android 中无法渲染。有人知道如何在Android设备上设置位置:“绝对”?
Button: {
position: "absolute",
right: 0,
top: 0,
borderRadius: 4,
borderWidth: 2,
width: 100,
height: 40,
borderColor: 'red',
backgroundColor: "rgb(72, 120, 166)",
}
Run Code Online (Sandbox Code Playgroud)
将 Button 包裹在 View 中适用于 Android 和 iOS:
import React, { Component } from 'react';
import { Text, View, StyleSheet, Button } from 'react-native';
export default class App extends Component {
render() {
return (
<View style={styles.container}>
<View style={styles.buttonView}>
<Button style={styles.button} title={"Click"}/>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
paddingTop: Constants.statusBarHeight,
backgroundColor: '#ecf0f1',
},
buttonView: {
position: "absolute",
right: 0,
top: 0
},
button:{
borderRadius: 4,
borderWidth: 2,
width: 100,
height: 40,
borderColor: 'red',
backgroundColor: "rgb(72, 120, 166)",
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15424 次 |
| 最近记录: |