我在使用setColorFilter方法时遇到了问题,这与IT技术有关。该方法在Android 2.2上运行良好,但在低于此版本的系统上无法正常工作。我的问题类似于Drawable.setColorFilter() not working on Android 2.1中所描述的问题,但对我无效。我使用以下代码,在Android 2.2上可以正常工作,但在低版本系统上无法正常工作。
任何有助于使其工作的线索都将不胜感激 :)
ImageView imageView = (ImageView) findViewById( R.id.imageView1 );
Bitmap immutableBitmap = BitmapFactory.decodeResource( getResources(), R.drawable.mybitmap );
Bitmap mutableBitmap = immutableBitmap.copy( Bitmap.Config.ARGB_8888, true );
immutableBitmap.recycle();
immutableBitmap = null;
Drawable d1 = new BitmapDrawable( mutableBitmap );
d1.setColorFilter( 0xff00ffff, PorterDuff.Mode.MULTIPLY );
imageView.setImageDrawable( d1 );
任何有助于使其工作的线索都将不胜感激 :)