我想知道我是如何在 xamarin 的C#代码中添加WindowManager
LayoutParams
标记的。
例如,我们可以通过以下代码在 Android 中执行此操作。
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON|
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD|
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED|
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
答案 0 :(得分:8)
像这样:
namespace SampleCode
{
[Activity (Label = "SampleCode", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
Window.AddFlags(WindowManagerFlags.KeepScreenOn|
WindowManagerFlags.DismissKeyguard|
WindowManagerFlags.ShowWhenLocked|
WindowManagerFlags.TurnScreenOn);
}
}
}