Android error PorterDuff.Mode: PorterDuff cannot be resolved by variable

I have a class that extends LinearLayout, cannot figure out how to get PorterDuff.Mode to work with this piece of code:

this.getBackground().setColorFilter(Color.parseColor("#a7d2e3"), PorterDuff.Mode.DARKEN);

"PorterDuff cannot be resolved to a variable"

I have imported porterduff and from what I see, PorterDuff is a static class. Any ideas?

+5
source share
2 answers

Add this to your import, because for some reason Eclipse does not automatically do this for this:

import android.graphics.PorterDuff;

+28
source

Use only Mode.DARKENand then importandroid.graphics.PorterDuff.Mode;

+1
source

All Articles