在 React Native 中,如何将图像对齐到视图的右侧?
In React Native, how do I align image to the right of a view?
我正在尝试将图像定位到 React Native 中视图的右侧。我需要得到如下所示的内容:
以下是我的样式表的样子。我对使用绝对定位感到紧张,因为我使用的是计算出的 marginBottom,它在不同的屏幕尺寸上可能看起来不同:
gamesBar: {
marginBottom: heightWindow * .1,
textAlign: 'center',
fontSize: 30,
backgroundColor: 'seagreen',
padding: 50,
color: 'white',
},
如果你把它和图片放在同一个View里,并且使用position absolute,那么它就是相对于图片的位置。只需相应地设置父视图 flex 即可。另一种方法是将文本和图像的父视图设置为 flex-direction: 'row' 然后将要对齐的图像设置为 flex-end.
我正在尝试将图像定位到 React Native 中视图的右侧。我需要得到如下所示的内容:
以下是我的样式表的样子。我对使用绝对定位感到紧张,因为我使用的是计算出的 marginBottom,它在不同的屏幕尺寸上可能看起来不同:
gamesBar: {
marginBottom: heightWindow * .1,
textAlign: 'center',
fontSize: 30,
backgroundColor: 'seagreen',
padding: 50,
color: 'white',
},
如果你把它和图片放在同一个View里,并且使用position absolute,那么它就是相对于图片的位置。只需相应地设置父视图 flex 即可。另一种方法是将文本和图像的父视图设置为 flex-direction: 'row' 然后将要对齐的图像设置为 flex-end.