简体   繁体   English

如何从操作栏中删除菜单(java)

[英]How to remove the menu from an action bar (java)

I'm new to android development and wanted to make a tabbed application, so I started with google's file form the documentation and I would like to remove the most above part of the action bar (where the logo and the app name stands). 我是android开发的新手,想制作一个选项卡式应用程序,因此我从Google文档的文档开始着手,我想删除操作栏最上面的部分(徽标和应用程序名称所在的位置)。 I've tried styling it like this: 我尝试过这样的样式:

<resources>
<style name="ThemeHoloWithActionBar" parent="android:Theme.Holo.Light.DarkActionBar">
    <item name="android:actionBarTabStyle">@style/ActionBarTabStyle</item>

    <item name="android:actionBarSize">50dip</item>
</style>

<style name="ActionBarTabStyle" parent="@android:style/Widget.Holo.ActionBar.TabView">
    <item name="android:minHeight">50dip</item>
</style>

hoping that it would push the size of the other bar to 0 but it didn't work. 希望它将另一栏的大小推到0,但没有用。

Edit: when using: 编辑:使用时:

<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>

I Can't get the error formatted correctly so I uploaded an image : 我无法正确格式化错误,因此我上传了图片:

http://i.imgur.com/ED7InpD.jpg http://i.imgur.com/ED7InpD.jpg

If you don't need the action bar, you can remove it from your entire app or from individual activities. 如果您不需要操作栏,则可以将其从整个应用程序或单个活动中删除。 This is appropriate for apps that never used the options menu or for apps in which the action bar doesn't meet design needs (such as games). 这适用于从未使用选项菜单的应用程序或操作栏不满足设计需求的应用程序(例如游戏)。 You can remove the action bar using a theme such as Theme.Holo.NoActionBar or Theme.DeviceDefault.NoActionBar. 您可以使用主题(例如Theme.Holo.NoActionBar或Theme.DeviceDefault.NoActionBar)删除操作栏。

in style.xml add this: 在style.xml中添加以下内容:

<resources>
    <style name="NoActionBar" parent="@android:style/Theme.Holo.NoActionBar">
        <!-- Your style here -->
    </style>
</resources>

in AndroidManifest.xml add this: 在AndroidManifest.xml中添加以下内容:

<!-- [...] -->
    <application android:name="@style/NoActionBar"
<!-- [...] -->

or try with this: 或尝试这样做:

<!-- [...] -->
    <application android:theme="@style/NoActionBar">
<!-- [...] -->

To remove actionbar, you need add: 要删除操作栏,您需要添加:

<item name="android:windowNoTitle">true</item> 
<item name="windowActionBar">false</item> 

to your AppTheme style file, after remove, then you can not use default actionbar to add tabs. 到您的AppTheme样式文件中,然后将其删除,则无法使用默认操作栏添加标签。

If you still want to use tabs, then you have to use SlidingTabLayout to make a custom ViewPager title strip. 如果仍要使用选项卡,则必须使用SlidingTabLayout制作自定义ViewPager标题栏。 There is Android sample project SlidingTabsBasic , which show detail how to make custom tabs. Android示例项目SlidingTabsBasic ,显示了如何制作自定义标签的详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM