隐藏Android操作栏解决方案

隐藏Android操作栏解决方案,android,android-actionbar,hide,Android,Android Actionbar,Hide,我一直在寻找隐藏Android操作栏的解决方案。其中数十个已经发布,并且以同样的方式工作——动作栏只有在第二次显示后才被隐藏。不够好,所以我进行了更多的测试,并创建了自己的解决方案。它并没有在任何地方发表,但对我来说似乎非常简单和明显。最重要的是,动作条根本看不见 我的问题是——这有什么问题?)为什么安卓恐龙会避免这样的事情 隐藏Android操作栏的解决方案: 明显地 android:theme="@style/CustomActionBarTheme" 在themes.xml中 <

我一直在寻找隐藏Android操作栏的解决方案。其中数十个已经发布,并且以同样的方式工作——动作栏只有在第二次显示后才被隐藏。不够好,所以我进行了更多的测试,并创建了自己的解决方案。它并没有在任何地方发表,但对我来说似乎非常简单和明显。最重要的是,动作条根本看不见

我的问题是——这有什么问题?)为什么安卓恐龙会避免这样的事情

隐藏Android操作栏的解决方案:

明显地

 android:theme="@style/CustomActionBarTheme"
在themes.xml中

<style name="CustomActionBarTheme"
       parent="@style/Theme.AppCompat.Light.DarkActionBar">
    <item name="android:actionBarStyle">@style/MyActionBar</item>

    <!-- Support library compatibility -->
    <item name="actionBarStyle">@style/MyActionBar</item>
</style>

<!-- ActionBar styles -->
<style name="MyActionBar"
    parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
    <item name="android:layout_marginBottom">-50dp</item>
</style>

@样式/MyActionBar
@样式/MyActionBar
-50dp

正如你所看到的,我只使用了负数marginBottom。

你应该只使用
Theme.AppCompat.Light.NoActionBar
-它会根据动作条的名称完全删除动作条。

如果你不想使用
动作条
,那么你必须使用
Theme.AppCompat.Light.NoActionBar
主题

在主题中为AndroidManifest.xml中的活动应用以下内容:

<activity android:name=".Activity"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.NoTitleBar">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
我希望有帮助

使用此
parent=“Theme.AppCompat.Light.NoActionBar”
让这成为你的风格

<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
true
假的
真的
@空的
欲知更多信息,请核对答案。我希望这将对您有所帮助。

我只需在
/res/values/style.xml
中更改父项值即可:

<resources>
  <!-- Base application theme. -->
  <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
  </style>
</resources>

这对我很管用

<resources>
  <!-- Base application theme. -->
  <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
  </style>
</resources>