Xamarin 表单 - Lottie 动画 - CarouselView
我正在使用最新版本的 Xamarin Forms 和 Lottie 包。 我正在尝试在轮播视图中绑定lottie 动画。问题是在我滚动所有幻灯片后洛蒂动画开始。 (如果我不滚动动画是空白的) 我的 carouselview xaml 是:
<CarouselView
PositionChanged="TheCarousel_PositionChanged"
x:Name="TheCarousel"
AbsoluteLayout.LayoutBounds="0,0,1,1"
AbsoluteLayout.LayoutFlags="All"
IndicatorView="indicatorview">
<CarouselView.ItemTemplate>
<DataTemplate>
<AbsoluteLayout>
<StackLayout
AbsoluteLayout.LayoutBounds=
"0.5,0.3,AutoSize,AutoSize"
AbsoluteLayout.LayoutFlags=
"PositionProportional"
HorizontalOptions="Center"
>
<forms:AnimationView
x:Name="animationView"
Animation="{Binding animazione}"
AnimationSource="EmbeddedResource"
CacheComposition="True"
AutoPlay="{Binding autoplay}"
RepeatMode="Infinite"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand" />
<Label
FontSize="Title"
HorizontalOptions="Center"
HorizontalTextAlignment="Center"
Text="{Binding testo}"
VerticalOptions="Center" />
</StackLayout>
</AbsoluteLayout>
</DataTemplate>
</CarouselView.ItemTemplate>
</CarouselView>
我通过代码填充它:
TheCarousel.BatchBegin();
intro = new ObservableCollection<Intro>();
var intro1 = new Intro { color1 = Color.Red, color2 = Color.Red, testo = "Hello 1", animazione = "Assets.71216-delivery-guy.json", autoplay = true };
var intro2 = new Intro { color1 = Color.RosyBrown, color2 = Color.Red, testo = "Hello 2", animazione = "Assets.pagamento-carte.json", autoplay = true };
intro.Add(intro1);
intro.Add(intro2);
TheCarousel.ItemsSource = intro;
TheCarousel.BatchCommit();
为什么会发生这种情况?
I'm using the latest version of Xamarin Forms and Lottie package.
I'm trying to bind lottie animation in carouselview. The problem is lottie animation start after i have scrolled all the slides. (if i not scroll the animation is blank)
my carouselview xaml is:
<CarouselView
PositionChanged="TheCarousel_PositionChanged"
x:Name="TheCarousel"
AbsoluteLayout.LayoutBounds="0,0,1,1"
AbsoluteLayout.LayoutFlags="All"
IndicatorView="indicatorview">
<CarouselView.ItemTemplate>
<DataTemplate>
<AbsoluteLayout>
<StackLayout
AbsoluteLayout.LayoutBounds=
"0.5,0.3,AutoSize,AutoSize"
AbsoluteLayout.LayoutFlags=
"PositionProportional"
HorizontalOptions="Center"
>
<forms:AnimationView
x:Name="animationView"
Animation="{Binding animazione}"
AnimationSource="EmbeddedResource"
CacheComposition="True"
AutoPlay="{Binding autoplay}"
RepeatMode="Infinite"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand" />
<Label
FontSize="Title"
HorizontalOptions="Center"
HorizontalTextAlignment="Center"
Text="{Binding testo}"
VerticalOptions="Center" />
</StackLayout>
</AbsoluteLayout>
</DataTemplate>
</CarouselView.ItemTemplate>
</CarouselView>
and i populate it via code:
TheCarousel.BatchBegin();
intro = new ObservableCollection<Intro>();
var intro1 = new Intro { color1 = Color.Red, color2 = Color.Red, testo = "Hello 1", animazione = "Assets.71216-delivery-guy.json", autoplay = true };
var intro2 = new Intro { color1 = Color.RosyBrown, color2 = Color.Red, testo = "Hello 2", animazione = "Assets.pagamento-carte.json", autoplay = true };
intro.Add(intro1);
intro.Add(intro2);
TheCarousel.ItemsSource = intro;
TheCarousel.BatchCommit();
Why this happen ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论