下面是我的代码,它在视图中显示图像和文本,文本被截断为i样式图像
</ScrollView>
<View style={{ flex: 1 }}>
<Image
source={require("../../assets/bannerImages/1.jpg")}
resizeMode={"center"}
style={{ height: "30%", width: "100%" }}
/>
<Text style={{ flex: 1 }}>
1Aawaz is a one step solution for all. Not only popular instruments
2like Guitar, Keyboard, Drums but also we provide training for rare
3Aawaz is a one step solution for all. Not only popular instruments
4like Guitar, Keyboard, Drums but also we provide training for rare
5Aawaz is a one step solution for all. Not only popular instruments
like Guitar, Keyboard, Drums but also we provide training for rare
Aawaz is a one step solution for all. Not only popular instruments
like Guitar, Keyboard, Drums but also we provide training for rare
like Guitar, Keyboard, Drums but also we provide training for rare
Aawaz is a one step solution for all. Not only popular instruments
like Guitar, Keyboard, Drums but also we pr like Guitar, Keyboard,
9Drums but also we provide training for rare Aawaz is a one step
10solution for all. Not only popular instruments like Guitar,
Keyboard, 13Drums but also we pr Ads
</Text>
</View>
</ScrollView>
我想要的是显示图像下方的文本,也能够给图像的宽度和高度。在设计图像样式之前,一切正常,文本没有被剪切。
此问题仅在Android上存在,并且您的代码在iOS上工作正常。它由图像的样式决定,您尝试将图像的高度设置为屏幕高度的 30%。
style={{ height: "30%", width: "100%" }}
图像的高度计算正确,但没有添加到< code>ScrollView的总高度中。该问题仅在使用百分比设置图像高度时出现,在使用数值时工作正常。解决这个问题的一个方法是使用React-Native的维度
首先,我们需要获得屏幕高度const{height}=Dimensions。get('window')
,然后计算屏幕的30%以设置图像高度const imageHeight=(30/100)*height
解决方案如下:
import React from 'react';
import { Text, View, ScrollView, Image, Dimensions } from 'react-native';
const { height } = Dimensions.get('window');
const imageHeight = (30 / 100) * height; // calculates 30% of the screen
<ScrollView>
<View style={{ flex: 1 }}>
<Image
source={require("../../assets/bannerImages/1.jpg")}
resizeMode={"center"}
style={{ height: imageHeight, width: "100%" }}
/>
<Text style={{ flex: 1 }}>
1Aawaz is a one step solution for all. Not only popular instruments
2like Guitar, Keyboard, Drums but also we provide training for rare
3Aawaz is a one step solution for all. Not only popular instruments
4like Guitar, Keyboard, Drums but also we provide training for rare
5Aawaz is a one step solution for all. Not only popular instruments
like Guitar, Keyboard, Drums but also we provide training for rare
Aawaz is a one step solution for all. Not only popular instruments
like Guitar, Keyboard, Drums but also we provide training for rare
like Guitar, Keyboard, Drums but also we provide training for rare
Aawaz is a one step solution for all. Not only popular instruments
like Guitar, Keyboard, Drums but also we pr like Guitar, Keyboard,
9Drums but also we provide training for rare Aawaz is a one step
10solution for all. Not only popular instruments like Guitar,
Keyboard, 13Drums but also we pr Ads
</Text>
</View>
</ScrollView>
问题内容: 我正在读取一个JSON文件,其中包含某些人的名称和图像URI。在遍历结构时,我可以打印名称,但无法显示图像。我也看到了那个阵营不支持动态图像,所以我做了一个解决办法的建议在这里。 JSON格式 主要成分 问题答案: 根据您期望的图像数量,您可以尝试将文件放置在文件夹中,如下所示: 然后在您的中,如果您要剪裁 资产:/中的 部分字符串,则可以使用: 如果要处理大量图像,则文件将变得难以维
从上面的图像中可以看到,一些文本被剪掉了:(代码: FONT:http://www.dafont.com/digital-7。FONT 如有任何帮助,我将不胜感激
我基本上尝试了这个问题的每个答案,但似乎没有任何效果:React原生文本离开我的屏幕,拒绝换行。怎么办? 我面临着同样的问题,我的文本离开屏幕,似乎以大约130%左右的宽度运行。 这是我呈现列表的屏幕: 这是聊天预览组件,其中消息文本会离开屏幕:
我试图创建一个小行星游戏,但我已经在一开始就很挣扎了:我想在游戏开始前创建一个倒计时。为了做到这一点,我使用了一个计时器,当按下按钮“开始”时开始,它(应该)每秒钟加载一个,然后显示在一个上。 在我加上计时器之前,整个程序运行得很好。然而,图像仍在绘制中,的方法仍在完全使用。但是,图像不会出现在我的上。 有人能发现错误吗?我真的不明白问题是什么,虽然我对计时器不熟悉,所以如果我做的事情真的很愚蠢,
我错过了什么??
我尝试从数组中随机加载gif。我尝试了几种方法,但都没有奏效。我要么收到错误消息,要么图像就不会出现。 版本 1(结果:图像未显示): 版本2(结果:“无效调用”) 版本3(结果:无法加载图像): 有什么想法吗?