2015-08-28 75 views
0

我一直在寻找隐藏Android Action Bar的解决方案。其中有数十种是以相同的方式发布和操作的 - 操作栏仅在显示第二种后才会隐藏。不够好,所以我测试了更多,并创建了我自己的解决方案。它没有出版在任何地方,但对我来说很简单明显。最重要的是 - Action Bar根本看不到。隐藏Android Action Bar解决方案

我的问题是 - 它有什么问题? )为什么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> 

正如你可以看到我只使用负marginBottom。

回答

1

您应该只使用Theme.AppCompat.Light.NoActionBar - 它会根据名称完全删除操作栏。

0

如果你不想使用ActionBar那么你有使用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> 

可以隐藏ActionBar编程也。

ActionBar actionBar = getActionBar(); or getSupportActionBar(); 
actionBar.hide(); 

我希望它有帮助!

1

使用此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> 

欲了解更多信息,您可以检查SO答案。我希望它会帮助你。 Full Screen Theme for AppCompat