【发布时间】:2018-08-23 18:25:27
【问题描述】:
到目前为止,我还没有找到这个简单问题的任何答案:
如何为BackgroundImage 设置动画?
BackgroundImage = "1.jpg"; // <--- initial
countdown = new System.Timers.Timer();
countdown.Interval = 2000;
countdown.Elapsed += (sender, e) =>
{
if (BackgroundImage == "1.jpg")
{
System.Diagnostics.Debug.WriteLine("change background to 2");
Device.BeginInvokeOnMainThread(() =>
{
BackgroundImage = "marcus.jpg";
});
}
else
{
System.Diagnostics.Debug.WriteLine("change background to 1");
Device.BeginInvokeOnMainThread(() =>
{
BackgroundImage = "1.jpg";
});
}
};
countdown.Enabled = true;
现在我想玩这个背景,而不是改变它,我非常想模仿 Apple 的照片在幻灯片上所做的事情:
-
最初背景是
1.jpg - 移动用动画朝一个方向移动
-
淡入背景到
2.jpg - 冲洗并在两者之间重复循环图像
但是,我不知道如何检索图像对象以便对其进行动画处理。
请注意,我不想要gif,只想要简单的静止图像。
【问题讨论】:
-
请阅读文档。你正在做的不是动画。 docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/…
-
@Greggz 我现在所做的不是,但我想要的是为页面的
BackgroundImage设置动画,而不是页面内的图像(我可以轻松地做到这一点)。跨度> -
假设您也可以获得
Image参考,我看不出有什么不同。请发布您尝试执行此操作的实际代码
标签: xamarin xamarin.forms