ImageView src未在xml中显示



我已经在drawables中粘贴了一个图像文件,但它没有显示在XML文件中。

在下面的代码中,"src"之后的部分得到了红色的高亮显示,尽管我在Drawable中有相同的命名文件。

这是XML代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Splash">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/splashImage" 
android:src="@drawable/splash"
<LinearLayout
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="@mipmap/ic_launcher"**
/>

1-确保您的XML文件是格式正确的

2-确保你的图像名称没有特殊字符,然后清理你的项目

如果这不起作用

尝试使缓存无效并重新启动(文件->使缓存无效和/重新启动(

你可以试试这个:

  • 清理并重建项目
  • 关闭并重新打开AndroidStudio
  • 检查图像文件的格式是否正确或能够读取

最新更新