我的应用程序屏幕上有一些元素,我希望最后一个元素位于右下角(我在Android上使用Expo客户端)。这是
render()
函数来自
App.js
以下内容:
render() {
return (
<View style={styles.container}>
<StatusBar
hidden={true}
/>
<TodoItem/>
<TodoItem/>
<TodoItem/>
<AddTodoButton style={styles.button}/>
</View>
);
}
所以,这是
<AddTodoButton\>
我想定位的。以下是我使用的样式:
const styles = StyleSheet.create({
container: {
backgroundColor: '#fcf7e2',
height: '100%',
},
button: {
position: 'absolute',
bottom: 0,
right: 0,
}
});
的代码
AddTodoButton
如下:
const Button = () => (
<Text style={styles.button}>+</Text>
);
const styles = StyleSheet.create({
button: {
fontSize: 30,
paddingLeft: 21,
paddingTop: 7,
width: 60,
height: 60,
backgroundColor: '#FF4456',
borderRadius: 60/2,
overflow: 'hidden',
}
});
我尝试了几种不同的风格
button
属性,但元素没有响应,并且在三个元素之后被贴到左边缘
<TodoItem/>
(除了
<Text>
从现在起)。
我很高兴在flexbox中这样做,只是我不知道如何并且在尝试时设法完全弄乱了布局。注意:|
有什么想法吗?