.Net-Avalonia学习笔记(十一)-安卓APP设置横屏与全屏
一、横屏
1、原本在Android中设置
2、参考上例在Avalonia中设置
在 MainActivity 中设置安卓应用为横屏模式,以下
[Activity(
Label = "AvaloniaTestApp.Android",
Theme = "@style/MyTheme.NoActionBar",
Icon = "@drawable/icon",
MainLauncher = true,
ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize | ConfigChanges.UiMode,
ScreenOrientation =ScreenOrientation.Landscape)]
public class MainActivity : AvaloniaMainActivity<App>
{
protected override AppBuilder CustomizeAppBuilder(AppBuilder builder)
{
//RequestedOrientation=ScreenOrientation.Landscape;
return base.CustomizeAppBuilder(builder)
.WithInterFont();
}
}
二、全屏
using Avalonia.Controls;
using System;
using System.Drawing;
using System.Threading;
using System.Threading.Tasks;
namespace AvaloniaApp1.Views;
public partial class MainView : UserControl
{
public MainView()
{
InitializeComponent();
}
private void Button_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
Console.WriteLine("12334432112");
var insetsManager = TopLevel.GetTopLevel(this).InsetsManager;
insetsManager.IsSystemBarVisible = false;
insetsManager.DisplayEdgeToEdge = true;
}
private void UserControl_Loaded(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
Console.WriteLine("223333111");
var insetsManager = TopLevel.GetTopLevel(this).InsetsManager;
insetsManager.IsSystemBarVisible = false;
insetsManager.DisplayEdgeToEdge = true;
}
}
本文来自博客园,作者:꧁执笔小白꧂,转载请注明原文链接:https://www.cnblogs.com/qq2806933146xiaobai/p/18567167