.NET MAUI BusyIndicator中的动画
BusyIndicator提供了用于控制其内置动画的大小和颜色的选项,并允许您定义自定义动画。
内置的动画
要更改BusyIndicator的选定动画,请使用其AnimationType
财产。AnimationType
是否接受来自的值的enumAnimation1
来Animation10
.默认情况下,AnimationType
设置为Animation1
.
动画只会在
IsBusy
属性设置为真正的
.
控制尺寸和颜色
要更改动画元素(动画内容)的大小和颜色,请使用以下属性:
AnimationContentWidthRequest
而且AnimationContentHeightRequest
-定义动画大小。AnimationColor
自定义内置动画的颜色。
AnimationContentWidthRequest
,AnimationContentHeightRequest
,AnimationColor
如果你使用自定义动画将不会被应用。
默认情况下,动画内容的大小是25x25像素。
下面的代码片段展示了如何配置预定义的BusyIndicator动画。
< / telerik: RadBusyIndicator >
下图显示了修改后的BusyIndicator处于繁忙状态。
自定义动画
属性的组合可创建自定义动画AnimationType
,BusyContent
,动画
属性:
控件要指示控件使用自定义动画,请设置
AnimationType
来自定义
.添加您想要动画的内容
BusyContent
.自定义动画被添加到
动画
BusyIndicator的集合。
下面的例子演示了如何在XAML中创建一个自定义动画来改变文本的不透明度(闪烁效果)。
RadDoubleAnimation动画=新的RadDoubleAnimation(){持续时间= 800,From = 0.1, To = 1, PropertyPath = "不透明度",目标= radBusyIndicator。BusyContent, RepeatForever = true, AutoReverse = true};this.radBusyIndicator.Animations.Add (annimation);Device.StartTimer(TimeSpan.FromMilliseconds(5000), () => {this.radBusyIndicator.IsBusy = false;返回错误;});
下面的示例演示如何创建一个自定义动画,该动画在代码隐藏中更改文本的不透明度(闪烁效果)。
RadBusyIndicator RadBusyIndicator = new RadBusyIndicator() {IsBusy = true, AnimationType = AnimationType。自定义,Content = new Label() { Text = "This is the content of the RadBusyIndicator control displayed when the indicator is not busy." }, BusyContent = new Label() { Text = "Loading...", VerticalOptions = new LayoutOptions(LayoutAlignment.Center, false), HorizontalOptions = new LayoutOptions(LayoutAlignment.Center, false), }, }; RadDoubleAnimation annimation = new RadDoubleAnimation() { Duration = 800, From = 0.1, To = 1, PropertyPath = "Opacity", Target = radBusyIndicator.BusyContent, RepeatForever = true, AutoReverse = true }; radBusyIndicator.Animations.Add(annimation); Device.StartTimer(TimeSpan.FromMilliseconds(5000), () => { radBusyIndicator.IsBusy = false; return false; });