Setting images in code (still) doesn't work on Android
See original GitHub issueDescription
It has been said this would have been fixed but its not. Its broken in RC2 and still broken in RC3. Setting an image from an URL (or from a stream doesn’t matter) in code does not show up in Android. Could test it on iOS and its broken there too.
Steps to Reproduce
public partial class MyPage : ContentPage
{
public MyPage()
{
InitializeComponent();
MyImageControl = new Image
{
Source = ImageSource.FromStream(() => new MemoryStream(Convert.FromBase64String("your image base64 string here")))
// OR:
// Source = ImageSource.FromUri(new Uri("your image URL here"))
};
}
}
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<Image x:Name="MyImageControl" />
</ContentPage>
Version with bug
Release Candidate 3 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android, iOS
Affected platform versions
Android 11, Pixel 5, Android Simulator on Windows, iOS 15
Did you find any workaround?
See https://github.com/dotnet/maui/issues/7074#issuecomment-1182933173
Relevant log output
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:19 (6 by maintainers)
Top Results From Across the Web
Android ImageView Is Not Displaying Image?
In ImageView there is two options src and srcCompact. Try both of them to find out which is working. android:src="@drawable/slide_view_4".
Read more >Add images to your Android app
In this codelab, you will learn how to add images to your app using an ImageView. ... How to create and run a...
Read more >Add images to your Android app
In this codelab, you learn how to add images to your app using an Image composable. ... Basic knowledge of how to create...
Read more >Troubleshoot known issues with Android Emulator
This page lists known issues, workarounds, and troubleshooting tips for the Android Emulator. If you encounter an issue not listed here or ...
Read more >Take photos
This lesson explains how to capture photos using an existing camera ... You want to take photos with minimal fuss, not reinvent the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mattleibow Ah okay that makes sense. Then I’ll try it like @jsuarezruiz did. If it still doesn’t work that way (which I assume is not the case) I will create a new issue. Thanks for the explanation.
This seems to be broken on Windows too, not just Android and iOS.
Saving to filesystem and using ImageSource.FromFile works as a workaround.