I use DatePicker
in Xamarin.Forms.
On UWP and virtual Android device, it works well. This is a screenshot of virtual device.
But on real android device, it doesn't work on.
Why does this problem occur?
Version of my real device is Android11, so I changed target version. However, the problem doesn't solve.
Is the function not compatible with Android 11?
And then, A switch button doesn't display well too.
~ Add ~
On Android11 virtual device, The function works well.
This is my code
MainPage.cs
public partial class MainPage : ContentPage {
public MainPage() {
InitializeComponent();
}
public async void newpage(object sender, EventArgs e) {
await Navigation.PushAsync(new addPage());
}
}
addPage(excerpt)
<StackLayout BackgroundColor="White"
Orientation="Horizontal"
Padding="7,5,5,5"
>
<Label Text=" 開始日時"
FontSize="17"
TextColor="Black"
HorizontalOptions="Start"
VerticalOptions="Center"/>
<DatePicker x:Name="startTimePicker"
Format="yyyy/MM/dd"
Date="2021/01/30"
HorizontalOptions="End" />
</StackLayout>
I found solution!
Dark theme is caused this problem, so turning off the function resolve this.
Or Add this code onCreate in MainActivity.cs
AppCompatDelegate.DefaultNightMode = AppCompatDelegate.ModeNightNo;