【发布时间】:2017-01-23 17:06:04
【问题描述】:
它在 Android Studio 预览中显示图像,但当我在我的设备上运行它时没有显示任何内容。任何想法为什么会发生这种情况?我的代码有什么问题?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/myimage" />
</RelativeLayout>
【问题讨论】:
-
你试过清理和重建你的项目吗?
-
现在试过了,没用。图像仍然不会显示。
-
愚蠢的问题,但可以肯定的是,您实际上是在使用布局,对吗?在 java 中使用
setContentView,我的意思是Activity。 -
是的,请检查
Activity中的代码,您是否使用了正确的布局setContentView。 -
是的。我试图在这个 ImageView 下添加一个 TextView。 TextView 显示,但 ImageView 不可见。