У меня есть 3 кнопки ImageButton на «Странице языков», которые представляют 3 различных языка приложения (Android).
<ContentPage.Resources>
<ResourceDictionary>
<Style x:Key="flagsImageButtonStyles" TargetType="ImageButton">
<Setter Property="HeightRequest"
Value="130" />
<Setter Property="WidthRequest"
Value="130" />
<Setter Property="Aspect" Value="AspectFill" />
<Setter Property="BackgroundColor" Value="Transparent" />
</Style>
</ResourceDictionary>
</ContentPage.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="1.5*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
...
<ImageButton Grid.Row="1" StyleId="fr" Grid.Column="1" x:Name="btnFrench" Clicked="LanguageButton_Clicked" Style="{StaticResource flagsImageButtonStyles}"/>
<ImageButton Grid.Row="2" StyleId="nl" Grid.Column="1" x:Name="btnDutch" Clicked="LanguageButton_Clicked" Style="{StaticResource flagsImageButtonStyles}"/>
<ImageButton Grid.Row="3" StyleId="en" Grid.Column="1" x:Name="btnEnglish" Clicked="LanguageButton_Clicked" Style="{StaticResource flagsImageButtonStyles}"/>
</Grid>
Я установил источник кнопок ImageButton следующим образом:
protected override void OnAppearing()
{
switch (CrossMultilingual.Current.CurrentCultureInfo.TwoLetterISOLanguageName) // "fr", "nl", "en"
{
case "fr":
btnFrench.Source = "fr_flag_selected.png";
btnDutch.Source = "nl_flag.png";
btnEnglish.Source = "en_flag.png";
break;
case "nl":
btnFrench.Source = "fr_flag.png";
btnDutch.Source = "nl_flag_selected.png";
btnEnglish.Source = "en_flag.png";
break;
case "en":
btnFrench.Source = "fr_flag.png";
btnDutch.Source = "nl_flag.png";
btnEnglish.Source = "en_flag_selected.png";
break;
}
base.OnAppearing();
}
Каждый раз, когда я нажимаю на одну из них, я устанавливаю язык и перехожу на другую страницу.
Поэтому в следующий раз, когда будет загружена «Страница языков», она проверит текущий язык и адаптирует исходные коды ImageBUtton.
Проблема заключается в том, что всякий раз, когда я нажимаю на одну из кнопок ImageButtonили если приложение переходит в спящий режим, кнопка ImageButton становится ОЧЕНЬ МАЛЕНЬКОЙ.
Есть идеи, что может быть не так?