Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 556
Redshirt Avatar asked Jan 13 '14 00:01

Redshirt


2 Answers

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.

like image 153
T.V. Avatar answered Oct 04 '22 08:10

T.V.


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);
    }
like image 25
ejohansson Avatar answered Oct 04 '22 07:10

ejohansson