Android actionbar gradient glitch

381 views Asked by At

My app actionbar has a gradient as background:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:startColor="@color/black"
        android:endColor="@android:color/transparent"
        android:angle="-90"/>
</shape>

It is applied to some activities programmatically using actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.background_black_gradient));

The problem is that some times, when I run the app (even without changing the binary), the actionbar shows a dark contour (see image). It happens both in my Nexus 7 (2012) and in the emulator, and it seems to only happen with API 21.

Does any one else ever seen something like that? Does anyone know how to fix it?

Thanks!

1

There are 1 answers

0
Myat Min Soe On BEST ANSWER

It's the shadow of the Action Bar. You can remove it by using this line of code.

getSupportActionBar().setElevation(0);