图像显示在Android Studio中但不在手机上显示
如下所示,这是Android Studio显示的内容:
As you can see below this is what Android Studio shows:
然而,当我在手机上运行此应用时,列表视图只显示空白图像(即 - 空格)在它上面的彩虹上的某个地方应该是。
However, when I run this app on my phone the List View shows with just a blank image (i.e - a space) above it where the "somewhere over the rainbow" should be.
列表视图工作正常。它由一个图像视图和两个文本视图组成。 (如果有帮助,此图像视图正常工作)。如果其中任何一个可能会干扰,那么我会在这里发布代码,但我发现很难相信。
The List View is working fine. It consists of one image view and 2 text views. (This image view is working if it helps). If any of this is possibly interfering then I will post the code here, but I find that hard to believe.
我不确定的一件事是我是否能够在单独的xml文件中为列表视图定义单元格时使用相对视图。我不明白为什么不能,但这是我唯一能想到的。
The one thing that I was unsure of was whether I could use relative view when defining the cells for the list view in the separate xml file. I don't see why not but it's the only thing that I could think of.
基本上Android工作室显示一切正常但在手机/模拟器上并非如此。因此,我发现很难找到问题。
Basically Android studio shows everything working but on the phone/emulator it is not the case. Hence, I am finding it very hard to locate the problem.
我是Android开发领域的新手,所以对我来说很容易。
I'm new to the Android development scene so go easy on me.
编辑
图片为.png格式,位于drawable文件夹中。我在drawable文件夹中还有另一个.png图像,似乎没有任何问题。为什么会这样?原始图片显然没有损坏,因为它显示在Android Studio中
The image is .png format and is located in the drawable folder. I also have another .png image in the drawable folder that seems to give no problems. Why is this the case? The original image is clearly not corrupt as it shows up in Android Studio
解决方案
因大小而无法将图像移动到mipmap-xxhdpi文件夹
Had to move image to "mipmap-xxhdpi" folder due to size
我今天发现了同样的问题。因此,首先检查图像的高度和宽度,并根据它将图像放入不同的可绘制文件夹。即如果图像尺寸为1280 x 840而不是将图像放入drawable-xxhdpi文件夹中。
I found same problem today . So first check height and width of image and based on it put image into different drawable folder. i.e If image size is 1280 x 840 than put image in drawable-xxhdpi folder.