简体   繁体   English

如何在 android 项目中使用 xamarin 显示图像

[英]How to display image using xamarin in android project

I trying to display a images in android project using xamarin.我尝试使用 xamarin 在 android 项目中显示图像。

  1. I put folder Images in my android project in directory Resources/drawable/Images我将文件夹Images放在我的 android 项目的Resources/drawable/Images目录中

  2. I set on every image property AndroidResource from BuildAction (I'm not sure if that should be the case)我从BuildAction设置了每个图像属性AndroidResource (我不确定是否应该是这种情况)

  3. In the c# code I try to call the image with this code but not worked for me:在 c# 代码中,我尝试使用此代码调用图像,但对我不起作用:

     if (descriptionForecast1 == "clear sky") { ImageDescriptionForecast1.Source = "Images/ClearSky.jpg"; ImageForecast1.Source = "Images/ClearSky.jpg"; }

Can I get an example of how to call the Images, because I get an error like this that the path is wrong:我可以获得一个如何调用图像的示例,因为我收到这样的错误,即路径错误:

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Aapt2.targets(3,3): Error APT2144: invalid file path '/Users/pizhev/Projects/WeatherLocationInfo 0.0.1/WeatherLocationInfo.Android/obj/Debug/res/drawable/images/lightrain1.jpg'. (APT2144) (WeatherLocationInfo.Android)

from the docs文档

Android - Place images in the Resources/drawable directory with Build Action: AndroidResource. Android - 使用 Build Action: AndroidResource 将图像放置在 Resources/drawable 目录中。 High- and low-DPI versions of an image can also be supplied (in appropriately named Resources subdirectories such as drawable-ldpi, drawable-hdpi, and drawable-xhdpi).还可以提供图像的高和低 DPI 版本(在适当命名的资源子目录中,例如 drawable-ldpi、drawable-hdpi 和 drawable-xhdpi)。

do not create your own sub-folders in Resources不要在资源中创建自己的子文件夹

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 xamarin 在 iOS 项目中的堆栈布局上显示背景图像 - How to display Image for background on stacklayout in iOS project using xamarin 如何使用Xamarin Android压缩图像但不调整大小? - How to Compress Image but not resize it Using Xamarin Android? 如何使用图像中的绑定标签在 xamarin 表单上显示图像 - how to display an image on xamarin forms using binding tag from image 如何在图像按钮中显示来自 URL 的图像 - xamarin Android - How to display an image from URL in imagebutton - xamarin Android 使用 Xamarin Android,如何在任务完成前显示进度条? - Using Xamarin Android, how to display progressbar before task is complete? 如何使用 Xamarin 在 Android 上的图库中请求保存图像的授权? - How to ask authorization for save image in Gallery on Android using Xamarin? 如何使用片段中的相机在Xamarin Android中捕获图像 - How to capture an image in xamarin android using the camera in fragment 使用Xamarin Android在片段中显示timerpickerdialog - Display timerpickerdialog within a fragment using Xamarin Android 如何以 Xamarin 形式显示 gif 图像? - How to display gif image in Xamarin form? 如何直接或通过Visual Studio将图像添加到Android模拟器(Xamarin Project) - How to Add an Image to Android Emulator Directly or through Visual Studio (Xamarin Project)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM