Android ImageView无法显示图片?

39

有人能告诉我为什么以下代码不起作用吗? 图像根本没有出现。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"

   <ImageView
          android:src="@drawable/splashscreen"
          android:scaleType="center"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" />

</RelativeLayout>

1
RelativeLayout没有方向..... - Rishabh Srivastava
4
如果你在 Android Api 21 或更低版本中运行应用程序,那么这是一个常见的问题。主要原因是你使用了高分辨率、大尺寸的图片。我建议你缩小图片大小,调整尺寸。 - Amiraslan
1
对我有用,谢谢! - 68060
32个回答

-1
许多与图像相关的问题可以通过使用第三方库(如Jake Wharton的Picasso)来解决。我在加载图像时遇到了一些无法解释的问题,有时甚至会出现内存溢出错误。这主要是由于使用Gimp for Mac进行图像编辑引起的。Picasso会处理内存和必要的缓存等繁重工作。

http://square.github.io/picasso/


问题的重点在于图片没有显示出来。Picasso的目的完全不同。 - Ashok Koyi

-1
如果由于某些布局错误,您的代码中的图像未显示,您可以使用usetools:ignore="contentDescription"工具。
在代码中使用usetools:ignore="contentDescription"这一行。
请注意,此方法仅适用于特定情况。

没有区别 - James Blackburn

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接