简体   繁体   English

LeftNavBar在活动顶部创建黑条

[英]LeftNavBar creates black bar at the top of the activity

I'm trying to incorporate Google's LeftNavBarLibrary into my application. 我正在尝试将Google的LeftNavBarLibrary合并到我的应用程序中。 When I load the nav bar I end up with a black bar across the top of the activity. 当我加载导航栏时,我最终在活动顶部有一个黑条。 The bar appears to be taking up the space a traditional actionbar would occupy. 酒吧似乎占据了传统动作栏所占据的空间。

Does anyone know where the bar is coming from or how to remove it. 有谁知道酒吧的来源或如何删除它。

Thanks. 谢谢。

在此输入图像描述

My application theme is slightly customized. 我的应用主题是略微定制的。 Based on the AppCompat theme due to requirements of the MediaRouteActionProvider 由于MediaRouteActionProvider的要求,基于AppCompat主题

styles.xml styles.xml

<resources>
    <style name="AppTheme" parent="@style/Theme.AppCompat">
        <item name="android:actionBarStyle">@style/MyActionBar</item>
    </style>

    <style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar">
        <item name="android:background">@drawable/ab_gradient</item>
    </style>
</resources>

The activity pictured above has a custom theme defined in the manifest. 上图所示的活动在清单中定义了自定义主题。

AndroidManifest.xml AndroidManifest.xml中

<activity
    android:name="my.app.namespace.CoreActivity"
    android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen" >
</activity>

The applications minimum sdk version is 14. So it's not exclusively a Google TV app. 应用程序最低sdk版本为14.因此它不仅仅是Google TV应用程序。 I've only been able to test this bug on my Android 4.1 and 4.4 devices. 我只能在我的Android 4.1和4.4设备上测试这个bug。

I deal with the action bar this way: 我这样处理动作栏:

getActionBar().hide();

Try to put this in your main activity or the activity that is the parent and always present. 尝试将此项放在您的主要活动或父项活动中,并始终存在。 Don't bother about the theme in manifest, just set your theme with title bar and hide it through the code. 不要担心清单中的主题,只需使用标题栏设置主题并通过代码隐藏它。

Hope this helps. 希望这可以帮助。

Take a look at: Hide the Status Bar on Android 4.0 and Lower 看看: 在Android 4.0和更低版本上隐藏状态栏

Notice that this is in the <application> tag. 请注意,这是在<application>标记中。 That might help you. 这可能对你有帮助。

<application
    ...
    android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen" >
    ...
</application>

or programmatically: 或以编程方式:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // If the Android version is lower than Jellybean, use this call to hide
        // the status bar.
        if (Build.VERSION.SDK_INT < 16) {
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }
        setContentView(R.layout.activity_main);
    }

You can set android:windowActionBar style to false by setting custom theme. 您可以通过设置自定义主题将android:windowActionBar样式设置为false。 Note: In this case getActionBar() will return null. 注意:在这种情况下,getActionBar()将返回null。 If you remove the action bar using a theme, then the window will not allow the action bar at all. 如果使用主题删除操作栏,则窗口将根本不允许操作栏。

Thanks for the answers guys. 谢谢你的回答。 The real issue was actually that the LeftNavBar.java class was creating an artificial margin at the top of the screen. 真正的问题实际上是LeftNavBar.java类在屏幕顶部创建了一个人工边距。 I'd have thought that a google published library would be better than that, but apparently not. 我认为谷歌出版的图书馆会比这更好,但显然不是。

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

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