Home > database >  WebP images do not render on Xamarin.Android XML Layout Editor on Visual Studio 2022 during design t
WebP images do not render on Xamarin.Android XML Layout Editor on Visual Studio 2022 during design t

Time:04-07

I have a bunch of WebP images in my drawables folders for use in my Xamarin.Android app. When running the app in Emulator/Device the images show correctly.

The problem is they do not show during design on the xml editor.

Here is what it looks like:

enter image description here

Is there a way to make it show properly? When I mouse over the @drawable/image in the imageview src attribute it shows a small preview box of the image (correctly) but just not in the designer itself. It makes it very frustrating and difficult to visualize the layout.

Visual Studio 2022 is up to date.

CodePudding user response:

Do you mean XAML Previewer?

The XAML Previewer has been deprecated in Visual Studio 2019 version 16.8 and Visual Studio for Mac version 8.8, and replaced by the XAML Hot Reload feature in Visual Studio 2019 version 16.9 and Visual Studio for Mac version 8.9

Learn more about XAML Hot Reload in the documentation.

You can use XAML Hot Reload to replace it

CodePudding user response:

That is pretty much expected with Xamarin's Android Designer. It hasn't had any work done to it for at least two years, it is pretty much pathetic for doing anything with it. My webp images don't show up either.

The easiest way around this problem is to just use Android Studio's designer and then copy/paste your finished result from Android Studio into a new XML file in VS and ignore what it looks like. Alternatively, you can also use Beyond Compare to open the layouts in both projects - to do small adjustments and therefore keep the files in sync for when you need to revisit a layout.

I've complained about the designer for the last two years and I recently got an answer back from their bot that stated that my bug would not be addressed because it didn't have enough votes from fellow VS Xamarin.Android developers. What a wonderful way of supporting a product - reproducible bugs need votes before they will be addressed!!

My original bug report included a test project that would reproduce the exception contained within the bug report. In my opinion that seems to demonstrate the lack of interest Microsoft has in Xamarin.Android - most of their effort appears to be going into Maui which I have absolutely no interest in. The guy who was originally responsible for the designer left over two years ago and since then it has just been downhill all the way for the designer.

If you are intending to use Android's Navigation component - (Single activity/multiple fragments), then you should get ready to see that exception every time you open a layout. The workaround is to exclude the navigation graph from your project and then all the XML files will open without error. You just have to remember (which you won't - and you mumble again I must learn Kotlin) to include it back when you build.

Of course, when you do everything right - your app builds and deploys and runs fine just as it should.

  • Related