Redshirt
Redshirt

Reputation: 674

LeftNavBar creates black bar at the top of the activity

I'm trying to incorporate Google's LeftNavBarLibrary into my application. 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.

enter image description here

My application theme is slightly customized. Based on the AppCompat theme due to requirements of the MediaRouteActionProvider

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

<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. I've only been able to test this bug on my Android 4.1 and 4.4 devices.

Upvotes: 7

Views: 415

Answers (4)

T.V.
T.V.

Reputation: 793

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.

Upvotes: 2

ejohansson
ejohansson

Reputation: 2882

Take a look at: Hide the Status Bar on Android 4.0 and Lower

Notice that this is in the <application> tag. 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);
    }

Upvotes: 1

Redshirt
Redshirt

Reputation: 674

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. I'd have thought that a google published library would be better than that, but apparently not.

Upvotes: 0

user3222415
user3222415

Reputation: 1

You can set android:windowActionBar style to false by setting custom theme. Note: In this case getActionBar() will return null. If you remove the action bar using a theme, then the window will not allow the action bar at all.

Upvotes: 0

Related Questions