Lottie animation not showing for Xamarin iOS app - xamarin

I tried implementing Lottie animation in iOS app. It works fine in Android but not iOS. Just blank.
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:lottie="clr-namespace:Lottie.Forms;assembly=Lottie.Forms">
...
<ContentView>
<lottie:AnimationView
x:Name="historyLottie"
Animation="{AppThemeBinding Light=history-light.json, Dark=history-dark.json}"
RepeatMode="Restart"
AnimationSource="AssetOrBundle"
WidthRequest="100"
HeightRequest="100"
AutoPlay="True"
Speed="1"/>
</ContentView>
...
</ContentPage>
Output:
The animation should show at the top of the label. I added both json files as BundleResource in my iOS project. Tried adding them as EmbeddedResource Tried manually playing it in code behind. still none. I'm stuck.
The questions raised in StackOverflow (as of this writing) are all not working for me, and are for previous version of Com.Airbnb.Xamarin.Forms.Lottie. AnimationViewRenderer also does not have Init anymore.
Mac OS: Ventura 13.1
Xamarin Forms Version: 5.0.0.2545
Com.Airbnb.Xamarin.Forms.Lottie Version: 4.1.0
VS Version: Community 2022, 17.4.5
.NET Version: 6.0.12 (64-bit)

Related

Is Xamarin Forms CollectionView working on macOS?

I've migrated a settings page from Xamarin Forms ListView to CollectionView. All is working on iOS, but nothing is rendered on macOS.
I downgraded Xamarin Forms to 4.7 and pushed it all of the way up to the current preview of 5.0.0.1829-pre6. I've searched the source on git, and I can't even find a renderer for CollectionView. My searches on the web come back with nothing specific.
Is CollectionView supported on macOS? If not, what is the roadmap for support?
As of the current production release (4.8.X), 'CollectionView' is not supported on macOS, it is supported on the following platforms:
iOS
Android
UWP
There is no timeline for official support but I would hope it would become available in 5.X since that version will go into LTS when MAUI takes over. I checked the Xamarin GitHub repo and couldn't find an issue so I raised one for macOS support for CollectionView. Going to the repository is the best way to keep updated, if you show your support they are more likely to do the work 😊

Master details hamburger icon not showing in xamarin latest pre release 5.0.0.1791

I have a xamarin.forms app which uses a master Details page. I updated the xamarin.forms package to Latest 5.0.0.1791-pre5. The reason why I updated to latest pre release was I want to provide DynamicResource to LinearGradientBrush which have issues on Latest Stable 4.8.
Now after updating to latest pre release, the hamburger icon of master details page disappeared. When I downgraded to latest stable the icon shows. Is it only occurring to me or is this a bug of latest package?
After XF 5.0 ,MasterDetailPage has been renamed to FlyoutPage. This is a deprecation, so your app will work as before. To adopt this change, we recommend you rename MasterDetailPage in your projects to FlyoutPage. Check release note .
In your case ,as a workaround you could set a custom icon for the Master page .
<MasterDetailPage.Master>
<pages:MasterDetailPageMaster IconImageSource="test.png" />
</MasterDetailPage.Master>
And put the icon to iOS project ->Assets and Android Resource -> drawable .

Replicating the same font used in iOS settings using Xamarin Forms?

From what I can see the default font used in iOS is San Francisco.
I am creating a page of settings for my application and I would like to use this font. Can anyone tell me how I can access and be sure that my XF app is using this font With iOS?
You could set custom fonts in Forms .
in iOS
Firstly , download the font file (San Francisco.ttf) and place in your Resources folder. Make sure the build type is BundleResource.
In addition to this, on iOS you have to open up your info.plist, and add in the file names of the fonts you want to use.
<key>UIAppFonts</key>
<array>
<string>xxx.ttf</string>
</array>
###Using Custom Fonts
Now we get to actually using them. Because referencing fonts requires different syntax for each OS. To best accommodate this, in your Application Resources, it is good to define your fonts.
For iOS we take the exact name of the file, without the extension (without .ttf)
In Android , since we don't set the value , it will still display the default font .
<ResourceDictionary>
<OnPlatform x:TypeArguments="x:String" x:Key="NormalFont">
<On Platform="iOS" Value="xxx" /> //xxx is San Francisco.ttf file name without .ttf extension
</OnPlatform>
</ResourceDictionary>
Then to use the font, you just need to reference the key.
<StackLayout>
<Label Text="Welcome to Xamarin Forms! (San Francisco in iOS)" FontFamily="{StaticResource NormalFont}" />
</StackLayout>
###Update
As the default font of UIControl in iOS is Helvetica . San Francisco is available after iOS 9.0 . So it is necessary to download it if your app need to support iOS 8.0 and before . After iOS 9.0 you don't need to set the font any more . San Francisco is the default font in iOS .

React Native Image not working Android both in emulator and in device

<Image /> is shown in iOS simulator but not shown in Android emulator and device.
It's only not working when I use it as custom marker for google maps
<MapView.Marker
coordinate={this.state.spot}
>
<View style={styles.customMarker}>
<Image style={styles.marker}
source={images.customMarker}
resizeMode='stretch'
/>
</View>
</MapView.Marker>
it could be the problem with simulator as well as it happens with weak network
try completely resetting it. (as if it were a new iPhone). "Reset content and settings"
Keep an eye on your image url as well.
Rebuild your project and run . It works for me.

Why are my Xamarin UWP Images not showing up on device?

I am developing a Xamarin UWP app using ffimageloading. The images show up just fine on the Windows Phone emulator that I am running through Visual Studio, but when I deploy it to a device through the device portal all of the images are missing.
<ffimageloading:CachedImage Grid.Column="0" Grid.Row="1"
Source="{helpers:ImageResource MyProject.Assets.Images.music-doublenote.png}" />
The issue was the build configuration. By turning off "Compile with .NET Native tool chain" on the Build tab of Properties for the Release configuration of the main UWP app and deploying the app with WinAppDeployCmd.exe
I had the same problem whenever I kept the image file inside any folder (for. eg assests). But later i started keeping the images file in the main project folder; I didn't keep them inside any folders and they started to show up in the application.
To get "Compile with .NET Native tool chain" working you have to use UWP-specific overload of the Forms.Init call which allows to correctly include FFImageLoading assemblies for Xamarin.Forms usage:
// you'll need to add `using System.Reflection;`
List<Assembly> assembliesToInclude = new List<Assembly>();
//Now, add in all the assemblies your app uses
assembliesToInclude.Add(typeof (FFImageLoadingAssembliesHere).GetTypeInfo().Assembly);
//Also do this for all your other 3rd party libraries
Xamarin.Forms.Forms.Init(e, assembliesToInclude);
// replaces Xamarin.Forms.Forms.Init(e);
I also had the issue with images not showing up on my UWP app. The images were showing up on my Android project but not UWP. For me the solution was to add the file extension. For some reason "myimage" works on Android but not on UWP, has to include the file extension like "myimage.png". Just wanna leave this here for anyone else potentially experiencing the same issue.

Resources