我在Android Asset Studio中创建了一个图像,它给了我包含文件夹的zip文件:drawable-hdpi,drawable-mdpi,drawable-xhdpi,drawable-xxhdpi,drawable-xxxhdpi,每个文件夹包含不同比例的png图像。我在android项目的Resources / drawable文件夹中粘贴了这些文件夹。然后我创建了:
<ImageView
android:src="@android:drawable/ic_ac_unit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/imageView1" />
但屏幕上没有任何内容。在谷歌有很多例子,但它似乎是用于Android的Android,因为当我使用Xamarin.Android跟随它时,它不起作用。
所以我认为您的问题是您的ImageView图像来自Android系统,请尝试以下操作:
<ImageView
android:src="@drawable/ic_ac_unit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/imageView1" />
这应该得到纠正。你可能已经注意到我改变了android:src。你拥有的价值是:
机器人:SRC = “@机器人:可绘制/ ic_ac_unit”
而这正试图从Android OS的预定义drawables中获取名为“ic_ac_unit”的drawable,而不是来自drawables。这就是我所看到的问题。
此外,由Android Asset Studio创建的“可绘制分辨率”文件夹应直接粘贴到项目的Resources文件夹中,而不是在Resource / drawable文件夹中。