[英]How to display Image for background on stacklayout in iOS project using xamarin
[英]How to display image using xamarin in android project
我嘗試使用 xamarin 在 android 項目中顯示圖像。
我將文件夾Images
放在我的 android 項目的Resources/drawable/Images
目錄中
我從BuildAction
設置了每個圖像屬性AndroidResource
(我不確定是否應該是這種情況)
在 c# 代碼中,我嘗試使用此代碼調用圖像,但對我不起作用:
if (descriptionForecast1 == "clear sky") { ImageDescriptionForecast1.Source = "Images/ClearSky.jpg"; ImageForecast1.Source = "Images/ClearSky.jpg"; }
我可以獲得一個如何調用圖像的示例,因為我收到這樣的錯誤,即路徑錯誤:
/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)
從文檔
Android - 使用 Build Action: AndroidResource 將圖像放置在 Resources/drawable 目錄中。 還可以提供圖像的高和低 DPI 版本(在適當命名的資源子目錄中,例如 drawable-ldpi、drawable-hdpi 和 drawable-xhdpi)。
不要在資源中創建自己的子文件夾
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.