Search code examples
javaandroidxmlandroid-actionbarborder

Remove ActionBar Border


So, here is the problem.

enter image description here

This border is showing up and I would like to remove it or at least change opacity. There was a shadow drop before because of Lollipop version, but I removed that with actionBar.setElevation(0);

Here is actionbar code from my class:

final android.support.v7.app.ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setDisplayUseLogoEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayHomeAsUpEnabled(false);
    actionBar.setElevation(0);
    actionBar.setCustomView(R.layout.appbar_layout);

Here is my style code:

<resources>

<style name="Theme.Example" parent="@style/Theme.AppCompat.Light">
    <item name="actionBarStyle">@style/ActionBar.Solid.Example</item>
    <item name="android:toolbarStyle">@style/ToolbarStyle</item>
    <item name="toolbarStyle">@style/ToolbarStyle</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:actionModeBackground">@android:color/white</item>
</style>

<style name="ToolbarStyle" parent="@style/Widget.AppCompat.Toolbar">
    <item name="contentInsetStart">0dp</item>
    <item name="android:contentInsetStart">0dp</item>
    <item name="android:windowContentOverlay">@null</item>
</style>

<style name="ActionBar.Solid.Example" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
    <item name="background">@android:color/white</item>
    <item name="android:titleTextStyle">@style/ActionBarStyle.Transparent.TitleTextStyle</item>
    <item name="android:windowContentOverlay">@null</item>
</style>

<style name="ActionBarStyle.Transparent.TitleTextStyle" parent="@style/Widget.AppCompat.Light.ActionBar">
    <item name="android:background">@drawable/appbar_logo</item>
</style>


Solution

  • In your app styles set the following:

     <style name="MyTheme" parent="@style/Theme.AppCompat.Light">
        <item name="colorPrimary">BORDER COLOR HERE</item>
        <item name="colorPrimaryDark">@color/primaryDark</item>
    </style>
    

    And in your manifest:

    <application
        android:label="@string/app_name"
        android:theme="@style/MyTheme">
    ...
    </application>