在React Native中,如何将图像对齐到视图的右边?

问题描述 投票:0回答:1

我正在尝试将图像放置在React Native中视图的右侧。我需要得到类似以下内容的东西:

enter image description here

以下是我的样式表的外观。我对使用绝对定位感到担心,因为我使用的是计算出的marginBottom,并且在不同的屏幕尺寸下看起来可能有所不同:

    gamesBar: {
        marginBottom: heightWindow * .1,
        textAlign: 'center',
        fontSize: 30,
        backgroundColor: 'seagreen',
        padding: 50,
        color: 'white',
    },
react-native stylesheet
1个回答
0
投票

如果将其与图像放在同一视图中,并使用绝对位置,则它将相对于图像位置。只需相应地设置父视图flex。另一种选择是只将文本和图像的父视图置于flex-direction:“ row”,然后将要对齐的图像设置为flex-end。

© www.soinside.com 2019 - 2024. All rights reserved.