隐藏xamarin中的通知栏和标题栏

时间:2016-04-02 09:15:27

标签: c# android xamarin

在Styles.xml中

<style name="MyTheme.Splash" parent ="Theme.AppCompat.Light">
    <item name="android:windowBackground">@drawable/splash_screen</item>
    <item name="android:windowNoTitle">true</item>  
  </style>

在Activity.cs中

[Activity(Theme = "@style/MyTheme.Splash", MainLauncher = true, NoHistory = true )]

我使用下面的代码来隐藏标题栏

Window.RequestFeature(WindowFeatures.NoTitle); //This will Hide the title Bar
             this.Window.ClearFlags(WindowManagerFlags.Fullscreen); //to hide

但没有任何效果。如何隐藏标题栏和通知栏。感谢帮助。

1 个答案:

答案 0 :(得分:3)

添加主题:

&#39;资源/值/ NoTitleTheme.xml&#39;

<?xml version="1.0" encoding="UTF-8" ?>
<resources>
<style name="Theme.NoTitle" parent="android:Theme">
<item name="android:windowNoTitle">true</item>
 </style>
</resources>

使用主题:

 [Activity(Theme = "@style/Theme.NoTitle", MainLauncher = true, NoHistory = true)]

this.Window.ClearFlags(WindowManagerFlags.Fullscreen);// this hides status bar of particular activity