5

I've got a class which extends LinearLayout, can't figure out how to get PorterDuff.Mode working with this piece of code:

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

"PorterDuff cannot be resolved to a variable"

I've imported porterduff and from what I can see PorterDuff is a static class. Any ideas?

4

2 回答 2

28

将此添加到您的导入中,因为出于某种原因,Eclipse 不会自动为此执行此操作:

import android.graphics.PorterDuff;

于 2014-05-29T01:20:43.790 回答
1

仅使用Mode.DARKEN,然后导入android.graphics.PorterDuff.Mode;

于 2014-10-22T12:26:00.883 回答