使用xamarin表单删除Android上的顶栏

时间:2017-01-26 09:02:18

标签: c# xamarin xamarin.android xamarin.forms portable-class-library

我尝试了几种解决方案,包括:

options:{
    onClick: graphClickEvent
}

function graphClickEvent(event, array){
    if(array[0]){
    foo.bar;
    }
}

<item name="android:actionBarSize">0dp</item>

var activity = (Activity)Forms.Context;
this.Window.AddFlags(WindowManagerFlags.Fullscreen);

或活动字符串

RequestWindowFeature(WindowFeatures.NoTitle);

但我找不到任何有效的解决方案,或者更确切地说,删除了我的歌词,电池时间等,但我仍然保持相同的顶部栏,我怎么能完全删除它?

enter image description here

我在iOs上添加了:

Theme = "@style/MainTheme.FullScreen"

并且工作......但是他让我该死的:) 解决方案?

我使用xamarin表格pcl

我的styles.xaml

UIApplication.SharedApplication.SetStatusBarHidden(true, true);

4 个答案:

答案 0 :(得分:4)

|-client
|-imports
  |-ui
     |-page1
       |-page1.html
       |-page1.js
       |-page1.css
     |-page2
       |-page2.html
       |-page2.js
       |-page3.css

答案 1 :(得分:1)

 if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
 {
     Window.AddFlags(WindowManagerFlags.TranslucentStatus);

     return; 
 }

仅此一项不会将视图置于状态栏下方,而是摆脱状态栏下方的黑色空间(高度为20px左右)。

答案 2 :(得分:0)

我在Xamarin论坛上回答了类似的问题:

将这两项添加到您指定活动的主题中:

<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>

https://forums.xamarin.com/discussion/comment/248555

编辑:为了方便您,请将您的样式更改为 -

<resources>
  <style name="MainTheme.FullScreen" parent="MainTheme.Base">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowFullscreen">true</item>
  </style>
  <style name="MainTheme" parent="MainTheme.Base">
  </style>
  <!-- Base theme applied no matter what API -->
  <style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
    <!--We will be using the toolbar so no need to show ActionBar-->
    <item name="windowActionBar">false</item>
    <!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette -->
    <!-- colorPrimary is used for the default action bar background -->
    <item name="colorPrimary">#2196F3</item>
    <!-- colorPrimaryDark is used for the status bar -->
    <!--<item name="colorPrimaryDark">#0084CA</item>-->
    <!-- colorAccent is used as the default value for colorControlActivated
     which is used to tint widgets -->
    <item name="colorAccent">#2196F3</item>
    <!-- You can also set colorControlNormal, colorControlActivated
     colorControlHighlight and colorSwitchThumbNormal. -->
    <item name="windowActionModeOverlay">true</item>
    <!-- default -->
    <item name="android:buttonStyle">@style/NoShadowButton</item>

    <item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
  </style>

  <style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
    <item name="colorAccent">#2196F3</item>
  </style>
  <style name="NoShadowButton" parent="android:style/Widget.Button">
    <item name="android:stateListAnimator">@null</item>
  </style>
</resources>

答案 3 :(得分:0)

就我而言,它与此配合工作:

<?xml version="1.0" encoding="utf-8" ?>
<resources>

  <style name="MainTheme" parent="MainTheme.Base">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowFullscreen">true</item>
  </style>
  <!-- Base theme applied no matter what API -->
  <style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
    <item name="windowNoTitle">true</item>
    <!--We will be using the toolbar so no need to show ActionBar-->
    <item name="windowActionBar">false</item>
    <!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette -->
    <!-- colorPrimary is used for the default action bar background -->
    <item name="colorPrimary">#2196F3</item>
    <!-- colorPrimaryDark is used for the status bar -->
    <item name="colorPrimaryDark">#1976D2</item>
    <!-- colorAccent is used as the default value for colorControlActivated
         which is used to tint widgets -->
    <item name="colorAccent">#FF4081</item>
    <!-- You can also set colorControlNormal, colorControlActivated
         colorControlHighlight and colorSwitchThumbNormal. -->
    <item name="windowActionModeOverlay">true</item>

    <item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
  </style>

  <style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
    <item name="colorAccent">#FF4081</item>
  </style>
</resources>