我正在制作标签页,我在加载标签页时遇到闪烁问题。当我启动应用程序时,在启动屏幕后会出现我的选项卡页面,在该页面中,我已初始化本地数据库并从服务器获取用户详细信息。闪烁问题在我的标签页中非常有问题。我设置的图像将覆盖此屏幕的总屏幕,由于该图像的闪烁效果很容易让所有用户看到。我们如何解决这些闪烁效应,请提出任何想法。
示例代码:
xaml page:
<StackLayout HorizontalOptions = "FillAndExpand" VerticalOptions = "FillAndExpand">
<Grid>
<Image x:Name = "Image" Source = "{Binding ImageSource}" IsVisible="{Binding IosImageVisibility}" HorizontalOptions = "FillAndExpand" VerticalOptions = "FillAndExpand" Aspect = "AspectFill"/>
<StackLayout Padding = "10" HorizontalOptions = "FillAndExpand" VerticalOptions = "FillAndExpand">
<Label Text="Sample test? " VerticalOptions="Fill" VerticalTextAlignment="Start" HorizontalOptions="CenterAndExpand" TextColor="White" >
<Label.FontSize>
<OnIdiom x:TypeArguments ="x:Double" Phone ="26" Tablet ="35"/>
</Label.FontSize>
</Label>
</Grid>
</StackLayout>
xaml.cs:
public partial class SampleView()
{
InitializeComponent();
BindingContext = new SampleViewModel();
LoadBackgroundImages();
}
private async void LoadBackgroundImages()
{
Image.Source = "sample.jpg";
await TaskDelay(2000);
Image.Source = "sample2.jpg";
await TaskDelay(2000);
Image.Source = "sample2.jpg";
await TaskDelay(2000);
}
private void RepeatLoop()
{
LoadBackgroundImages();
}
SampleViewModel
public SampleViewModel()
{
InitializeDataBase();
GetUserDetailsFromServer();
}