Drawable.setColorFilter()不适用于Android 2.1
在Android 2.2(emulator)和2.3(N1)上,setColorFilter()工作正常。为什么它不能在2.1上工作(在emulator上测试)?另一个Android bug?你需要使你的Drawable.setColorFilter()不适用于Android 2.1,android,Android,在Android 2.2(emulator)和2.3(N1)上,setColorFilter()工作正常。为什么它不能在2.1上工作(在emulator上测试)?另一个Android bug?你需要使你的位图变为易变的 Drawable d = new BitmapDrawable(BitmapFactory.decodeResource( getResources(), R.drawable.ic_watch)); d.setColorFilter(new LightingColorF
位图变为易变的
Drawable d = new BitmapDrawable(BitmapFactory.decodeResource(
getResources(), R.drawable.ic_watch));
d.setColorFilter(new LightingColorFilter(color, lightenColor));
imageView.setImageDrawable(d);
你也可以看到这个问题突然出现
// make a mutable Bitmap
Bitmap immutableBitmap = BitmapFactory.decodeResource(getResources(),
R.drawable.ic_watch);
Bitmap mutableBitmap = immutableBitmap.copy(Bitmap.Config.ARGB_8888, true);
// you have two bitmaps in memory, so clean up the mess a bit
immutableBitmap.recycle(); immutableBitmap=null;
Drawable d = new BitmapDrawable(mutableBitmap);
// mutate it
d.setColorFilter(new LightingColorFilter(color, lightenColor));
imageView.setImageDrawable(d);