简体   繁体   English

ReactNative 在背景图像的特定位置重叠图像

[英]ReactNative overlap image on a specific location of background image

I want to place an image on a specific location of my background image, we can consider I am using the RN ImageBackground element and have a full width/height background image in it and the resizeMode is set to contain.我想在我的背景图像的特定位置放置一个图像,我们可以考虑我正在使用 RN ImageBackground 元素并且其中有一个完整的宽度/高度背景图像并且 resizeMode 设置为包含。 So now I want to add my logo to the Y location of the background image.所以现在我想将我的徽标添加到背景图像的 Y 位置。 How can I achieve this?我怎样才能做到这一点?

在此处输入图像描述

I tried to use marginTop for my image component but it won't be at the same location for every devices.我尝试将 marginTop 用于我的图像组件,但它不会在每个设备上都位于同一位置。 If the aspect ratio is different, then my image will go up or down and won't be located at the desired location.如果长宽比不同,那么我的图像将向上或向下 go,并且不会位于所需位置。 I also tried to handle it by using a formula like viewportHeight * 0.15 to achieve this but didn't work as expected..我还尝试通过使用像 viewportHeight * 0.15 这样的公式来处理它来实现这一点,但没有按预期工作。

I think the only way to handle it is by having a formula to maintain the marginTop property for every aspect ratio, what do you think?我认为处理它的唯一方法是使用一个公式来为每个宽高比维护 marginTop 属性,您怎么看?

just take BackgroundImage as your main view and in side backgroundimage create 4 another view vertically and inside the second view just place your logo it'll work same for all devices只需将 BackgroundImage 作为您的主视图,并在侧面 backgroundimage 中垂直创建 4 个另一个视图,并在第二个视图中放置您的徽标,它对所有设备都适用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM