Filipe Ramos
Filipe Ramos

Reputation: 1795

Android actionbar gradient glitch

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!

Upvotes: 0

Views: 355

Answers (1)

Myat Min Soe
Myat Min Soe

Reputation: 807

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

getSupportActionBar().setElevation(0);

Upvotes: 1

Related Questions