【问题标题】:How to use Uno Lottie on Android?如何在 Android 上使用 Uno Lottie?
【发布时间】:2020-04-07 14:29:48
【问题描述】:

创建了像这里所说的简单动画:https://docs.microsoft.com/en-us/windows/communitytoolkit/animations/lottie-scenarios/getting_started_json

<controls:AnimatedVisualPlayer AutoPlay="True" Width="90" Height="90">
    <lottie:LottieVisualSource UriSource="ms-appx:///Utils/17477-orange-payment.json"/>
<controls:AnimatedVisualPlayer>

它适用于 UWP,不适用于 Android。

我所引用的:

UWP
 <PackageReference Include="Microsoft.Extensions.Logging.Console">
      <Version>1.1.2</Version>
    </PackageReference>
    <PackageReference Include="Microsoft.Extensions.Logging.Filter">
      <Version>1.1.2</Version>
    </PackageReference>
    <PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
      <Version>6.2.10</Version>
    </PackageReference>
    <PackageReference Include="Microsoft.Toolkit.Uwp.UI.Lottie">
      <Version>6.0.0</Version>
    </PackageReference>
    <PackageReference Include="Microsoft.UI.Xaml">
      <Version>2.3.200213001</Version>
    </PackageReference>
    <PackageReference Include="Uno.Microsoft.Toolkit.Uwp.UI">
      <Version>5.1.0-build.200.gf9c311b069</Version>
    </PackageReference>
    <PackageReference Include="Uno.UI">
      <Version>2.1.37</Version>
    </PackageReference>
Android
 <PackageReference Include="Com.Airbnb.Android.Lottie">
      <Version>3.0.4</Version>
    </PackageReference>
    <PackageReference Include="Microsoft.UI.Xaml">
      <Version>2.3.200213001</Version>
    </PackageReference>
    <PackageReference Include="Uno.Microsoft.Toolkit.Uwp.UI">
      <Version>5.1.0-build.200.gf9c311b069</Version>
    </PackageReference>
    <PackageReference Include="Uno.UI" Version="2.2.0-dev.390" />
    <PackageReference Include="Uno.UI.Lottie">
      <Version>2.2.0-dev.390</Version>
    </PackageReference>
    <PackageReference Include="Uno.UniversalImageLoader" Version="1.9.32" />
    <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.2" />
    <PackageReference Include="Microsoft.Extensions.Logging.Filter" Version="1.1.2" />

应用在没有NotImplementedException 的情况下运行,在 Android 上只是透明的。 任何样品都会很棒!

【问题讨论】:

    标签: android uwp uno-platform


    【解决方案1】:

    也许您的 json 文件未正确捆绑/包含?

    在 WASM、iOS 和 macOS 上,您可以将 Lottie .json 文件直接放在共享项目的文件夹中(例如“Lottie/myanimation.json”)并将其构建操作设置为内容。

    在 Android 上,需要将 Lottie .json 文件添加到 Assets 文件夹中。为了匹配与其他平台相同的路径,该文件可以存储在“Assets/Lottie/myanimation.json”中。将其 Build 操作设置为 AndroidAsset。

    要在 XAML 中引用动画,请使用 ms-appx: URI,在本例中为 ms-appx:///Lottie/myanimation.json

    另外请注意,在 Android 上,FillStretch 模式目前不受支持。

    Uno Lottie Documentation reference

    其他可能性,但我注意到您的文件包含“-”,我知道 Android 讨厌图像中的那些字符,您可以尝试重命名您的文件。

    【讨论】:

      猜你喜欢
      • 2018-09-30
      • 2018-08-19
      • 2021-06-15
      • 2021-12-27
      • 2021-04-03
      • 2021-10-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-16
      相关资源
      最近更新 更多