Skip to content Skip to sidebar Skip to footer

Removing Line Or Divider Between Action Bar And Main Screen In Android

How can I remove line or divider between action bar and main screen? How can I change the color of this divider in android? Thanks in advance.

Solution 1:

Simply insert the attribute windowContentOverlay to your theme. It's way too simple this way.

<stylename="AppTheme"parent="android:Theme.Holo.Light"><!-- Customize your theme here. --><itemname="android:windowContentOverlay">@null</item></style>

Solution 2:

On Kotlin, you can use supportActionBar?.elevation = 0f to remove the shadow of the ActionBar.

Add this code to the onCreate() function of the desired activity. For example:

overridefunonCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        // Hide ActionBar shadow
        supportActionBar?.elevation = 0f
    }

The ?. operator controls Null Pointer Exception if you have no ActionBar on this Activity.

Note: If you are not using AppCompat, call actionBar?.elevation = 0f instead.

Solution 3:

If you use AppCompat you need set parent="Theme.AppCompat", not "Theme.AppCompat.Light" (the same stands for ActionBar) :)

For example: @style/MyActionBar true @style/MyActionBar true

<stylename="MyActionBar"parent="Base.Widget.AppCompat.ActionBar"><itemname="android:background">@android:color/transparent</item><!--For compatibility--><itemname="background">@android:color/transparent</item></style>

Solution 4:

None of these solutions worked for me. I ended up adding this code to the onCreate() event of my MainActivity:

actionBar = getSupportActionBar();
actionBar.setElevation(0);

Solution 5:

This worked for me:

I just added the following line of code to the onCreate() method

getSupportActionBar().setElevation(0);

Post a Comment for "Removing Line Or Divider Between Action Bar And Main Screen In Android"